From 6e4ba7af14c281375133d825d47ccb56d6c6fa5d Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@factorcode.org>
Date: Thu, 21 Feb 2008 01:25:08 -0600
Subject: [PATCH] Ring benchmark optimization

---
 core/threads/threads.factor                    | 3 +++
 extra/benchmark/ring/ring.factor               | 4 +++-
 extra/concurrency/conditions/conditions.factor | 5 +++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/core/threads/threads.factor b/core/threads/threads.factor
index 0eecc70a27..23b1f04364 100755
--- a/core/threads/threads.factor
+++ b/core/threads/threads.factor
@@ -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 ;
 
diff --git a/extra/benchmark/ring/ring.factor b/extra/benchmark/ring/ring.factor
index f1b7d6c9cc..ae918b7ebc 100755
--- a/extra/benchmark/ring/ring.factor
+++ b/extra/benchmark/ring/ring.factor
@@ -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 ; 
diff --git a/extra/concurrency/conditions/conditions.factor b/extra/concurrency/conditions/conditions.factor
index 4662f1b369..8126900dbc 100755
--- a/extra/concurrency/conditions/conditions.factor
+++ b/extra/concurrency/conditions/conditions.factor
@@ -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