threads: some cleanup.

db4
John Benediktsson 2014-12-02 16:44:24 -08:00
parent 00b1919725
commit 49270c2ac6
1 changed files with 11 additions and 9 deletions

View File

@ -1,10 +1,10 @@
! Copyright (C) 2004, 2011 Slava Pestov. ! Copyright (C) 2004, 2011 Slava Pestov.
! Copyright (C) 2005 Mackenzie Straight. ! Copyright (C) 2005 Mackenzie Straight.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: alien.private arrays hashtables heaps kernel kernel.private USING: accessors alien.private arrays assocs boxes combinators
math namespaces sequences vectors continuations continuations.private continuations continuations.private deques dlists fry hashtables
dlists assocs system combinators init boxes accessors math.order heaps init kernel kernel.private math math.order namespaces
deques strings quotations fry ; quotations sequences strings system ;
FROM: assocs => change-at ; FROM: assocs => change-at ;
IN: threads IN: threads
@ -92,7 +92,8 @@ sleep-entry ;
: unregister-thread ( thread -- ) : unregister-thread ( thread -- )
id>> threads delete-at ; id>> threads delete-at ;
: set-self ( thread -- ) OBJ-CURRENT-THREAD set-special-object ; inline : set-self ( thread -- )
OBJ-CURRENT-THREAD set-special-object ; inline
PRIVATE> PRIVATE>
@ -135,9 +136,9 @@ PRIVATE>
: interrupt ( thread -- ) : interrupt ( thread -- )
dup state>> [ dup state>> [
dup sleep-entry>> [ sleep-queue heap-delete ] when* [
f >>sleep-entry [ sleep-queue heap-delete ] when* f
dup resume ] change-sleep-entry dup resume
] when drop ; ] when drop ;
DEFER: stop DEFER: stop
@ -202,7 +203,8 @@ PRIVATE>
[ context ] dip context>> >box [ context ] dip context>> >box
next (next) ; next (next) ;
: yield ( -- ) self resume f suspend drop ; : yield ( -- )
self resume f suspend drop ;
GENERIC: sleep-until ( n/f -- ) GENERIC: sleep-until ( n/f -- )