     stream>> [ serialize flush ] with-stream* ;
 
 M: remote-thread send ( message thread -- )
-    [ id>> 2array ] [ node>> ] [ get-thd-conn ] tri
+    [ id>> 2array ] [ node>> ] [ thread-connections at ] tri
     [ nip send-to-connection ] [ send-remote-message ] if* ;
 
 M: thread (serialize) ( obj -- )

C: <connection> connection

: connect ( remote-thread -- )
    dup node>> dup binary <client> <connection> set-thd-conn ;

: disconnect ( remote-thread -- )
    dup get-thd-conn [ stream>> dispose ] when* f set-thd-conn ;

: with-connection ( remote-thread quot -- )
    '[ connect @ ] over [ disconnect ] curry [ ] cleanup ; inline


: thread-connections ( -- hash )
    \ thread-connections get-global ;

PRIVATE>

