snit::type ten::future {
- variable callbacks
+ variable callbacks ""
variable is_ready 0
variable result ""
variable failure ""
}
method on_ready {cb_code} {
- lappend callbacks [list ready $cb_code]
+ if [$self is_ready] {
+ eval [concat $cb_code $self]
+ } else {
+ lappend callbacks [list ready $cb_code]
+ }
}
method on_done {cb_code} {
- lappend callbacks [list done $cb_code]
+ if [llength $result] {
+ eval [concat $cb_code [list $result]]
+ } else {
+ lappend callbacks [list done $cb_code]
+ }
}
method on_fail {cb_code} {
- lappend callbacks [list fail $cb_code]
+ if [llength $failure] {
+ eval [concat $cb_code [list $failure]]
+ } else {
+ lappend callbacks [list fail $cb_code]
+ }
}
method MarkReady {} {