|
|
|
|
@ -25,12 +25,13 @@ package ctasks
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"crns"
|
|
|
|
|
"opts"
|
|
|
|
|
"sync"
|
|
|
|
|
"sync/atomic"
|
|
|
|
|
"syncs/works"
|
|
|
|
|
"syns/works"
|
|
|
|
|
"time"
|
|
|
|
|
cronus "timers"
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
|
@ -41,7 +42,7 @@ type (
|
|
|
|
|
wgr sync.WaitGroup
|
|
|
|
|
|
|
|
|
|
parent Context
|
|
|
|
|
expiration *cronus.Expiration
|
|
|
|
|
expiration *crns.Expiration
|
|
|
|
|
|
|
|
|
|
mode Mode
|
|
|
|
|
state uint32
|
|
|
|
|
@ -77,7 +78,7 @@ func NewCompletion (options ...CompletionFnc) (*Completion,error) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if c.expiration == nil {
|
|
|
|
|
c.expiration = cronus.NewExpiration(0,nil)
|
|
|
|
|
c.expiration = crns.NewExpiration(0,nil)
|
|
|
|
|
}
|
|
|
|
|
return c,nil
|
|
|
|
|
}
|
|
|
|
|
@ -96,7 +97,7 @@ func (c *Completion) IsCompleted () bool {
|
|
|
|
|
return c.State() > StateStarted
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Completion) Chrono () cronus.Chronometer {
|
|
|
|
|
func (c *Completion) Chrono () crns.Chronometer {
|
|
|
|
|
return c.expiration.Chono() }
|
|
|
|
|
|
|
|
|
|
func (c *Completion) Result () Result {
|
|
|
|
|
@ -147,7 +148,7 @@ func (c *Completion) complete (ctx context.Context, cctx Context, cid int) error
|
|
|
|
|
// en tiempo de la completion en caso de que exista, o bien de la
|
|
|
|
|
// completion padre o bien del contexto.
|
|
|
|
|
//
|
|
|
|
|
var ex cronus.Expirer
|
|
|
|
|
var ex crns.Expirer
|
|
|
|
|
|
|
|
|
|
if cctx != nil {
|
|
|
|
|
c.parent = cctx
|
|
|
|
|
@ -330,7 +331,7 @@ func WithMode (mode Mode) opts.GOptionErrFnc[Completion] {
|
|
|
|
|
//
|
|
|
|
|
func WithTimeout (tmo time.Duration) opts.GOptionErrFnc[Completion] {
|
|
|
|
|
return func(c *Completion) error {
|
|
|
|
|
c.expiration = cronus.NewExpiration(tmo,func(){
|
|
|
|
|
c.expiration = crns.NewExpiration(tmo,func(){
|
|
|
|
|
c.notify(CompletionFromTimer, StateCanceled,nil,G.ErrCancelByTimer)
|
|
|
|
|
})
|
|
|
|
|
return nil
|
|
|
|
|
|