From 478af8e51cd7e20f3c013a291eb64e01033fa078 Mon Sep 17 00:00:00 2001 From: Doug Coleman <doug.coleman@gmail.com> Date: Mon, 5 Nov 2007 11:11:09 -0600 Subject: [PATCH] Store ms/continuation pairs in the sleep queue instead of tuples Updated for new heaps --- core/threads/threads.factor | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/core/threads/threads.factor b/core/threads/threads.factor index 95536db00c..b55bec6f85 100644 --- a/core/threads/threads.factor +++ b/core/threads/threads.factor @@ -10,22 +10,17 @@ continuations debugger dlists ; SYMBOL: sleep-queue -TUPLE: sleeping ms continuation ; - -M: sleeping <=> ( obj1 obj2 -- n ) - [ sleeping-ms ] 2apply - ; - : sleep-time ( -- ms ) sleep-queue get-global dup heap-empty? - [ drop 1000 ] [ heap-peek sleeping-ms millis [-] ] if ; + [ drop 1000 ] [ heap-peek first millis [-] ] if ; : run-queue ( -- queue ) \ run-queue get-global ; : schedule-sleep ( ms continuation -- ) - sleeping construct-boa sleep-queue get-global heap-push ; + 2array sleep-queue get-global heap-push ; : wake-up ( -- continuation ) - sleep-queue get-global heap-pop sleeping-continuation ; + sleep-queue get-global heap-pop second ; PRIVATE>