Ring benchmark optimization

db4
Slava Pestov 2008-02-21 01:25:08 -06:00
parent 2342169d87
commit 6e4ba7af14
3 changed files with 9 additions and 3 deletions
core/threads
extra
benchmark/ring
concurrency/conditions

View File

@ -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 ;

View File

@ -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 ;

View File

@ -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