Threads now inherit the namestack once again

db4
Slava Pestov 2008-02-24 02:18:50 -06:00
parent fe8354f2f1
commit b58d61a541
4 changed files with 7 additions and 10 deletions

View File

@ -1,6 +1,6 @@
USING: help.markup help.syntax kernel kernel.private io
threads.private continuations dlists init quotations strings
assocs heaps boxes ;
assocs heaps boxes namespaces ;
IN: threads
ARTICLE: "threads-start/stop" "Starting and stopping threads"
@ -127,7 +127,10 @@ HELP: spawn
{ $values { "quot" quotation } { "name" string } }
{ $description "Spawns a new thread. The thread begins executing the given quotation; the name is for debugging purposes. The new thread begins running immediately and the current thread is added to the end of the run queue."
$nl
"The new thread begins with an empty data stack, an empty catch stack, and a name stack containing the global namespace only. This means that the only way to pass data to the new thread is to explicitly construct a quotation containing the data, for example using " { $link curry } " or " { $link compose } "." }
"The new thread begins with an empty data stack, an empty retain stack, and an empty catch stack. The name stack is inherited from the parent thread but may be cleared with " { $link init-namespaces } "." }
{ $notes
"The recommended way to pass data to the new thread is to explicitly construct a quotation containing the data, for example using " { $link curry } " or " { $link compose } "."
}
{ $examples
{ $code "1 2 [ + . ] 2curry \"Addition thread\" spawn" }
} ;

View File

@ -165,7 +165,6 @@ M: f nap nap-until ;
resume-now [
dup set-self
dup register-thread
init-namespaces
V{ } set-catchstack
{ } set-retainstack
>r { } set-datastack r>

View File

@ -10,10 +10,6 @@ SYMBOL: servers
<PRIVATE
: spawn-vars ( quot vars name -- )
>r [ dup get ] H{ } map>assoc [ swap bind ] 2curry r>
spawn drop ;
LOG: accepted-connection NOTICE
: with-client ( client quot -- )
@ -26,8 +22,7 @@ LOG: accepted-connection NOTICE
: accept-loop ( server quot -- )
[
>r accept r> [ with-client ] 2curry
{ log-service servers } "Client" spawn-vars
>r accept r> [ with-client ] 2curry "Client" spawn drop
] 2keep accept-loop ; inline
: server-loop ( addrspec quot -- )

View File

@ -133,7 +133,7 @@ M: stack-display tool-scroller
: restart-listener ( listener -- )
dup com-end dup clear-output
[ listener-thread ] curry
[ init-namespaces listener-thread ] curry
"Listener" spawn drop ;
: init-listener ( listener -- )