From b58d61a541a709b98b90520543cc4afbe6840f51 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sun, 24 Feb 2008 02:18:50 -0600 Subject: [PATCH] Threads now inherit the namestack once again --- core/threads/threads-docs.factor | 7 +++++-- core/threads/threads.factor | 1 - extra/io/server/server.factor | 7 +------ extra/ui/tools/listener/listener.factor | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/core/threads/threads-docs.factor b/core/threads/threads-docs.factor index a8e4eef587..fa79906cdf 100755 --- a/core/threads/threads-docs.factor +++ b/core/threads/threads-docs.factor @@ -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" } } ; diff --git a/core/threads/threads.factor b/core/threads/threads.factor index 2ba5179c1c..70ed44e539 100755 --- a/core/threads/threads.factor +++ b/core/threads/threads.factor @@ -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> diff --git a/extra/io/server/server.factor b/extra/io/server/server.factor index 6cc11ea6b6..a76ebcc450 100755 --- a/extra/io/server/server.factor +++ b/extra/io/server/server.factor @@ -10,10 +10,6 @@ SYMBOL: servers 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 -- ) diff --git a/extra/ui/tools/listener/listener.factor b/extra/ui/tools/listener/listener.factor index 7617b0f32d..d828471609 100755 --- a/extra/ui/tools/listener/listener.factor +++ b/extra/ui/tools/listener/listener.factor @@ -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 -- )