mirror of
https://github.com/vlang/v.git
synced 2025-09-17 00:12:26 +03:00
vlib/context: add onecontext as submodule (#12549)
This commit is contained in:
parent
2144471ce1
commit
f7926ec9a4
6 changed files with 369 additions and 3 deletions
|
@ -44,9 +44,10 @@ pub fn with_deadline(mut parent Context, d time.Time) (Context, CancelFn) {
|
|||
dur := d - time.now()
|
||||
if dur.nanoseconds() <= 0 {
|
||||
ctx.cancel(true, deadline_exceeded) // deadline has already passed
|
||||
return Context(ctx), fn [mut ctx] () {
|
||||
cancel_fn := fn [mut ctx] () {
|
||||
ctx.cancel(true, canceled)
|
||||
}
|
||||
return Context(ctx), CancelFn(cancel_fn)
|
||||
}
|
||||
|
||||
if ctx.err() is none {
|
||||
|
@ -55,9 +56,11 @@ pub fn with_deadline(mut parent Context, d time.Time) (Context, CancelFn) {
|
|||
ctx.cancel(true, deadline_exceeded)
|
||||
}(mut ctx, dur)
|
||||
}
|
||||
return Context(ctx), fn [mut ctx] () {
|
||||
|
||||
cancel_fn := fn [mut ctx] () {
|
||||
ctx.cancel(true, canceled)
|
||||
}
|
||||
return Context(ctx), CancelFn(cancel_fn)
|
||||
}
|
||||
|
||||
// with_timeout returns with_deadline(parent, time.now().add(timeout)).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue