From: Matt S Trout Date: Sun, 9 Sep 2012 16:08:01 +0000 (+0000) Subject: add await_get and switch code to use it X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=47f04c562fa3f1001830a48ec4a9e15717d71976;p=scpubgit%2FTenDotTcl.git add await_get and switch code to use it --- diff --git a/t/connection.t b/t/connection.t index 41e0e2c..e0425c9 100644 --- a/t/connection.t +++ b/t/connection.t @@ -23,15 +23,9 @@ set ready_args "" $f1 on_ready [list apply {{name future} {set $name [$future get]}} "[namespace current]::ready_args" ] -$f1 retain - -$f1 await_ready - set my_host [exec hostname] -is [$f1 get] $my_host "hostname retuend ok via get" - -$f1 free +is [$f1 await_get] $my_host "hostname returned ok via get" is $ready_args $my_host "hostname returned ok via on_ready" diff --git a/ten/ten.tcl b/ten/ten.tcl index 3798233..a093a97 100644 --- a/ten/ten.tcl +++ b/ten/ten.tcl @@ -197,6 +197,19 @@ snit::type ten::future { vwait "${selfns}::is_ready" } + method await_get {} { + $self retain + $self await_ready + if [$self is_failure] { + set err [$self failure] + $self free + error $err + } + set res [$self get] + $self free + return $res + } + method retain {} { incr retain_count }