Ring benchmark optimization
parent
2342169d87
commit
6e4ba7af14
core/threads
extra
benchmark/ring
concurrency/conditions
|
@ -77,6 +77,9 @@ PRIVATE>
|
|||
: resume ( thread -- )
|
||||
check-registered run-queue push-front ;
|
||||
|
||||
: resume-now ( thread -- )
|
||||
check-registered run-queue push-back ;
|
||||
|
||||
: resume-with ( obj thread -- )
|
||||
check-registered 2array run-queue push-front ;
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ SYMBOL: done
|
|||
receive 2dup swap send done eq? [ tunnel ] unless ;
|
||||
|
||||
: create-ring ( processes -- target )
|
||||
self swap [ [ tunnel ] "Tunnel" spawn nip ] times ;
|
||||
self swap [
|
||||
dup [ tunnel ] curry "Tunnel" spawn nip
|
||||
] times ;
|
||||
|
||||
: send-messages ( messages target -- )
|
||||
dupd [ send ] curry each [ receive drop ] times ;
|
||||
|
|
|
@ -4,10 +4,11 @@ USING: dlists threads kernel arrays sequences ;
|
|||
IN: concurrency.conditions
|
||||
|
||||
: notify-1 ( dlist -- )
|
||||
dup dlist-empty? [ drop ] [ pop-back second resume ] if ;
|
||||
dup dlist-empty?
|
||||
[ drop ] [ pop-back second resume-now ] if ;
|
||||
|
||||
: notify-all ( dlist -- )
|
||||
[ second resume ] dlist-slurp yield ;
|
||||
[ second resume-now ] dlist-slurp yield ;
|
||||
|
||||
: wait ( queue timeout status -- )
|
||||
>r [ 2array swap push-front ] r> suspend 3drop ; inline
|
||||
|
|
Loading…
Reference in New Issue