Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
06801a0e
Commit
06801a0e
authored
Mar 18, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #940 from jbenet/goprocess-bugfix
updated goprocess -- bugfixes
parents
c5fbc667
7777a231
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
3 deletions
+47
-3
Godeps/Godeps.json
Godeps/Godeps.json
+1
-1
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
...rkspace/src/github.com/jbenet/goprocess/goprocess_test.go
+38
-0
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
.../_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
+8
-2
No files found.
Godeps/Godeps.json
View file @
06801a0e
...
...
@@ -207,7 +207,7 @@
},
{
"ImportPath"
:
"github.com/jbenet/goprocess"
,
"Rev"
:
"
b4efc4c8775f0250710b39bfa716276ca10f85af
"
"Rev"
:
"
140749d0a125caaf7c9a2893d166331e2e963a7a
"
},
{
"ImportPath"
:
"github.com/kardianos/osext"
,
...
...
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess_test.go
View file @
06801a0e
...
...
@@ -460,6 +460,44 @@ func TestCloseAfterChildren(t *testing.T) {
testStrs
(
t
,
Q
,
"a"
,
"d"
)
}
func
TestGoClosing
(
t
*
testing
.
T
)
{
var
ready
=
make
(
chan
struct
{})
a
:=
WithParent
(
Background
())
a
.
Go
(
func
(
p
Process
)
{
// this should be fine.
a
.
Go
(
func
(
p
Process
)
{
ready
<-
struct
{}{}
})
// set a to close. should not fully close until after this func returns.
go
a
.
Close
()
// wait until a is marked as closing
<-
a
.
Closing
()
// this should also be fine.
a
.
Go
(
func
(
p
Process
)
{
select
{
case
<-
p
.
Closing
()
:
// p should be marked as closing
default
:
t
.
Error
(
"not marked closing when it should be."
)
}
ready
<-
struct
{}{}
})
ready
<-
struct
{}{}
})
<-
ready
<-
ready
<-
ready
}
func
TestBackground
(
t
*
testing
.
T
)
{
// test it hangs indefinitely:
b
:=
Background
()
...
...
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
View file @
06801a0e
...
...
@@ -61,6 +61,8 @@ func (p *process) AddChildNoWait(child Process) {
select
{
case
<-
p
.
Closed
()
:
panic
(
"Process cannot add children after being closed"
)
case
<-
p
.
Closing
()
:
go
child
.
Close
()
default
:
}
...
...
@@ -78,6 +80,8 @@ func (p *process) AddChild(child Process) {
select
{
case
<-
p
.
Closed
()
:
panic
(
"Process cannot add children after being closed"
)
case
<-
p
.
Closing
()
:
go
child
.
Close
()
default
:
}
...
...
@@ -88,10 +92,12 @@ func (p *process) AddChild(child Process) {
func
(
p
*
process
)
Go
(
f
ProcessFunc
)
Process
{
child
:=
newProcess
(
nil
)
p
.
AddChild
(
child
)
waitFor
:=
newProcess
(
nil
)
child
.
WaitFor
(
waitFor
)
// prevent child from closing
// add child last, to prevent a closing parent from
// closing all of them prematurely, before running the func.
p
.
AddChild
(
child
)
go
func
()
{
f
(
child
)
waitFor
.
Close
()
// allow child to close.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment