mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-12-26 03:55:26 -05:00
better way to run tasks in parallel
This commit is contained in:
@@ -75,7 +75,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
return newError("failed to dispatch request").Base(err)
|
||||
}
|
||||
|
||||
requestDone := signal.ExecuteAsync(func() error {
|
||||
requestDone := func() error {
|
||||
defer inboundRay.InboundInput().Close()
|
||||
defer timer.SetTimeout(d.policy().Timeouts.DownlinkOnly)
|
||||
|
||||
@@ -86,9 +86,9 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
responseDone := signal.ExecuteAsync(func() error {
|
||||
responseDone := func() error {
|
||||
defer timer.SetTimeout(d.policy().Timeouts.UplinkOnly)
|
||||
|
||||
var writer buf.Writer
|
||||
@@ -113,9 +113,9 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
|
||||
if err := signal.ExecuteParallel(ctx, requestDone, responseDone); err != nil {
|
||||
inboundRay.InboundInput().CloseError()
|
||||
inboundRay.InboundOutput().CloseError()
|
||||
return newError("connection ends").Base(err)
|
||||
|
||||
Reference in New Issue
Block a user