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
bcae8392
Commit
bcae8392
authored
Jul 04, 2015
by
rht
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update goprocess godep
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
007a12e7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
9 deletions
+45
-9
Godeps/Godeps.json
Godeps/Godeps.json
+1
-1
Godeps/_workspace/src/github.com/jbenet/goprocess/context/context.go
...kspace/src/github.com/jbenet/goprocess/context/context.go
+34
-6
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go
...s/_workspace/src/github.com/jbenet/goprocess/goprocess.go
+1
-1
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
.../_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
+9
-1
No files found.
Godeps/Godeps.json
View file @
bcae8392
...
...
@@ -197,7 +197,7 @@
},
{
"ImportPath"
:
"github.com/jbenet/goprocess"
,
"Rev"
:
"
67fe91f1081e806f1bb51051c972ac782ea46d85
"
"Rev"
:
"
a6650d0b69f2aa0fe7c9685baf0b4d7ecc8766bf
"
},
{
"ImportPath"
:
"github.com/kardianos/osext"
,
...
...
Godeps/_workspace/src/github.com/jbenet/goprocess/context/context.go
View file @
bcae8392
...
...
@@ -10,19 +10,23 @@ import (
//
// func ProcessWithContext(ctx context.Context) goprocess.Process {
// p := goprocess.WithParent(goprocess.Background())
// go func() {
// <-ctx.Done()
// p.Close()
// }()
// CloseAfterContext(p, ctx)
// return p
// }
//
func
WithContext
(
ctx
context
.
Context
)
goprocess
.
Process
{
p
:=
goprocess
.
WithParent
(
goprocess
.
Background
())
CloseAfterContext
(
p
,
ctx
)
return
p
}
// WithContextAndTeardown is a helper function to set teardown at initiation
// of WithContext
func
WithContextAndTeardown
(
ctx
context
.
Context
,
tf
goprocess
.
TeardownFunc
)
goprocess
.
Process
{
if
ctx
==
nil
{
panic
(
"nil Context"
)
}
p
:=
goprocess
.
WithParent
(
goprocess
.
Background
())
p
:=
goprocess
.
WithTeardown
(
tf
)
go
func
()
{
<-
ctx
.
Done
()
p
.
Close
()
...
...
@@ -39,6 +43,30 @@ func WaitForContext(ctx context.Context, p goprocess.Process) {
p
.
WaitFor
(
WithContext
(
ctx
))
}
// CloseAfterContext schedules the process to close after the given
// context is done. It is the equivalent of:
//
// func CloseAfterContext(p goprocess.Process, ctx context.Context) {
// go func() {
// <-ctx.Done()
// p.Close()
// }()
// }
//
func
CloseAfterContext
(
p
goprocess
.
Process
,
ctx
context
.
Context
)
{
if
p
==
nil
{
panic
(
"nil Process"
)
}
if
ctx
==
nil
{
panic
(
"nil Context"
)
}
go
func
()
{
<-
ctx
.
Done
()
p
.
Close
()
}()
}
// WithProcessClosing returns a context.Context derived from ctx that
// is cancelled as p is Closing (after: <-p.Closing()). It is simply:
//
...
...
Godeps/_workspace/src/github.com/jbenet/goprocess/goprocess.go
View file @
bcae8392
...
...
@@ -114,7 +114,7 @@ type Process interface {
//
// It is useful to construct simple asynchronous workers, children of p.
Go
(
f
ProcessFunc
)
Process
// SetTeardown sets the process's teardown to tf.
SetTeardown
(
tf
TeardownFunc
)
...
...
Godeps/_workspace/src/github.com/jbenet/goprocess/impl-mutex.go
View file @
bcae8392
...
...
@@ -119,8 +119,16 @@ func (p *process) SetTeardown(tf TeardownFunc) {
if
tf
==
nil
{
tf
=
nilTeardownFunc
}
p
.
Lock
()
p
.
teardown
=
tf
if
p
.
teardown
==
nil
{
select
{
case
<-
p
.
Closed
()
:
p
.
teardown
=
tf
p
.
closeErr
=
tf
()
default
:
}
}
p
.
Unlock
()
}
...
...
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