Fix deadlock when deleting actors
This commit is contained in:
parent
3d25441e7a
commit
02f06d857e
@ -137,11 +137,13 @@ func (this *environment) Del(ctx context.Context, actors ...Actor) error {
|
|||||||
channels := []<- chan struct { } { }
|
channels := []<- chan struct { } { }
|
||||||
for _, actor := range actors {
|
for _, actor := range actors {
|
||||||
info := this.info(actor)
|
info := this.info(actor)
|
||||||
if info.done != nil {
|
if info.stopped != nil {
|
||||||
channels = append(channels, info.stopped)
|
channels = append(channels, info.stopped)
|
||||||
}
|
}
|
||||||
|
info.done()
|
||||||
}
|
}
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
|
if channel == nil { continue }
|
||||||
select {
|
select {
|
||||||
case <- channel:
|
case <- channel:
|
||||||
case <- ctx.Done():
|
case <- ctx.Done():
|
||||||
@ -250,7 +252,11 @@ func (this *environment) run(actor Actor) {
|
|||||||
// contains context information
|
// contains context information
|
||||||
info := this.info(actor)
|
info := this.info(actor)
|
||||||
ctx := info.ctx
|
ctx := info.ctx
|
||||||
defer close(info.stopped)
|
defer func() {
|
||||||
|
if info.stopped != nil {
|
||||||
|
close(info.stopped)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
switch actor := actor.(type) {
|
switch actor := actor.(type) {
|
||||||
case Runnable:
|
case Runnable:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user