change concurrency library to use new catch usage
parent
6b4227b022
commit
cd32714099
|
@ -128,12 +128,12 @@ M: crash-command run-rpc-command ( command -- shutdown? result )
|
|||
: (robust-rpc-server) ( worker -- )
|
||||
[
|
||||
receive over send
|
||||
] [
|
||||
[
|
||||
"Worker died, Starting a new worker" print
|
||||
drop [ handle-rpc-message ] spawn-linked-server
|
||||
] when
|
||||
] catch
|
||||
]
|
||||
catch
|
||||
[
|
||||
"Worker died, Starting a new worker" print
|
||||
drop [ handle-rpc-message ] spawn-linked-server
|
||||
] when
|
||||
(robust-rpc-server) ;
|
||||
|
||||
: robust-rpc-server ( -- process )
|
||||
|
|
|
@ -164,8 +164,7 @@ USING: kernel concurrency concurrency-examples threads vectors
|
|||
] spawn-link drop
|
||||
receive
|
||||
]
|
||||
[
|
||||
] catch
|
||||
catch
|
||||
] unit-test
|
||||
|
||||
[ 50 ] [
|
||||
|
|
|
@ -209,7 +209,7 @@ TUPLE: linked-exception error ;
|
|||
#! Same as spawn but if the quotation throws an error that
|
||||
#! is uncaught, that error gets propogated to the process
|
||||
#! performing the spawn-link.
|
||||
[ [ [ rethrow-linked ] when* ] catch ] cons
|
||||
[ catch [ rethrow-linked ] when* ] cons
|
||||
[ in-thread ] self make-linked-process [ with-process ] over slip ;
|
||||
|
||||
#! A common operation is to send a message to a process containing
|
||||
|
|
|
@ -349,9 +349,9 @@ can catch it:</p>
|
|||
"This will not print" print
|
||||
] spawn-link drop
|
||||
receive
|
||||
] [
|
||||
[ "Exception caught." print ] when
|
||||
] catch</span>
|
||||
]
|
||||
catch [ "Exception caught." print ] when
|
||||
</span>
|
||||
=> "Exception caught."
|
||||
</pre>
|
||||
<p>Exceptions are only raised in the parent when the parent does a
|
||||
|
@ -427,12 +427,12 @@ worker:</p>
|
|||
[
|
||||
#! Forward all messages to worker
|
||||
receive over send
|
||||
] [
|
||||
[
|
||||
"Worker died, Starting a new worker" print
|
||||
drop [ handle-rpc-message ] spawn-linked-server
|
||||
] when
|
||||
] catch
|
||||
]
|
||||
catch
|
||||
[
|
||||
"Worker died, Starting a new worker" print
|
||||
drop [ handle-rpc-message ] spawn-linked-server
|
||||
] when
|
||||
(robust-rpc-server) ;
|
||||
|
||||
: robust-rpc-server ( -- process )
|
||||
|
|
Loading…
Reference in New Issue