From 536a4a39325386c5ccd79f932140882d8f46e3cb Mon Sep 17 00:00:00 2001 From: Chris Double Date: Thu, 29 Oct 2009 18:39:25 +1300 Subject: [PATCH] Rename distributed process registry stuff to remote-thread --- basis/channels/remote/remote.factor | 13 ++++----- .../distributed/distributed-docs.factor | 18 ++++++------ .../distributed/distributed-tests.factor | 2 +- .../distributed/distributed.factor | 28 +++++++++---------- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/basis/channels/remote/remote.factor b/basis/channels/remote/remote.factor index 6f63b9bd4a..59dec91859 100644 --- a/basis/channels/remote/remote.factor +++ b/basis/channels/remote/remote.factor @@ -28,7 +28,7 @@ MATCH-VARS: ?from ?tag ?id ?value ; SYMBOL: no-channel -: channel-process ( -- ) +: channel-thread ( -- ) [ { { { to ?id ?value } @@ -41,10 +41,9 @@ SYMBOL: no-channel PRIVATE> : start-channel-node ( -- ) - "remote-channels" get-process [ - "remote-channels" - [ channel-process t ] "Remote channels" spawn-server - register-process + "remote-channels" get-remote-thread [ + [ channel-thread t ] "Remote channels" spawn-server + "remote-channels" register-remote-thread ] unless ; TUPLE: remote-channel node id ; @@ -53,12 +52,12 @@ C: remote-channel M: remote-channel to ( value remote-channel -- ) [ [ \ to , id>> , , ] { } make ] keep - node>> "remote-channels" swap + node>> "remote-channels" send-synchronous no-channel = [ no-channel throw ] when ; M: remote-channel from ( remote-channel -- value ) [ [ \ from , id>> , ] { } make ] keep - node>> "remote-channels" swap + node>> "remote-channels" send-synchronous dup no-channel = [ no-channel throw ] when* ; [ diff --git a/basis/concurrency/distributed/distributed-docs.factor b/basis/concurrency/distributed/distributed-docs.factor index 4672043b36..8ea7153b0b 100644 --- a/basis/concurrency/distributed/distributed-docs.factor +++ b/basis/concurrency/distributed/distributed-docs.factor @@ -21,23 +21,23 @@ $nl { $examples { $unchecked-example ": log-message ( -- ) receive . flush log-message ;" - "[ log-message ] \"logger\" spawn [ name>> ] keep register-process" + "[ log-message ] \"logger\" spawn dup name>> register-remote-thread" } } "This spawns a thread waits for the messages. It registers that thread as a " -"able to be accessed remotely using " { $link register-process } "." +"able to be accessed remotely using " { $link register-remote-thread } "." $nl "The second Factor instance, the one associated with port 9001, can send " -"messages to the 'logger' process by name:" +"messages to the 'logger' thread by name:" { $examples { $unchecked-example "USING: io.sockets concurrency.messaging concurrency.distributed ;" - "\"hello\" \"logger\" \"127.0.0.1\" 9000 send" + "\"hello\" \"127.0.0.1\" 9000 \"logger\" send" } } "The " { $link send } " word is used to send messages to other threads. If an " -"instance of " { $link remote-process } " is provided instead of a thread then " -"the message is marshalled to the named process on the given machine using the " +"instance of " { $link remote-thread } " is provided instead of a thread then " +"the message is marshalled to the named thread on the given machine using the " { $vocab-link "serialize" } " vocabulary." $nl "Running this code should show the message \"hello\" in the first Factor " @@ -45,15 +45,15 @@ $nl $nl "It is also possible to use " { $link send-synchronous } " to receive a " "response to a distributed message. When an instance of " { $link thread } " " -"is marshalled it is converted into an instance of " { $link remote-process } +"is marshalled it is converted into an instance of " { $link remote-thread } ". The receiver of this can use it as the target of a " { $link send } " or " { $link reply } " call." ; ARTICLE: "concurrency.distributed" "Distributed message passing" "The " { $vocab-link "concurrency.distributed" } " implements transparent distributed message passing, inspired by Erlang and Termite." { $subsections start-node } -"Instances of " { $link thread } " can be sent to remote processes, at which point they are converted to objects holding the thread ID and the current node's host name:" -{ $subsections remote-process } +"Instances of " { $link thread } " can be sent to remote threads, at which point they are converted to objects holding the thread ID and the current node's host name:" +{ $subsections remote-thread } "The " { $vocab-link "serialize" } " vocabulary is used to convert Factor objects to byte arrays for transfer over a socket." { $subsections "concurrency.distributed.example" } ; diff --git a/basis/concurrency/distributed/distributed-tests.factor b/basis/concurrency/distributed/distributed-tests.factor index b2a2851926..96955ac94b 100644 --- a/basis/concurrency/distributed/distributed-tests.factor +++ b/basis/concurrency/distributed/distributed-tests.factor @@ -25,7 +25,7 @@ IN: concurrency.distributed.tests [ 8 ] [ 5 self 2array - "thread-a" test-node send + test-node "thread-a" send receive ] unit-test diff --git a/basis/concurrency/distributed/distributed.factor b/basis/concurrency/distributed/distributed.factor index 325e8e3cc9..244f1d95a3 100644 --- a/basis/concurrency/distributed/distributed.factor +++ b/basis/concurrency/distributed/distributed.factor @@ -8,25 +8,25 @@ IN: concurrency.distributed -: register-process ( name process -- ) - swap registered-processes set-at ; +: register-remote-thread ( thread name -- ) + registered-remote-threads set-at ; -: unregister-process ( name -- ) - registered-processes delete-at ; +: unregister-remote-thread ( name -- ) + registered-remote-threads delete-at ; -: get-process ( name -- process ) - dup registered-processes at [ ] [ thread ] ?if ; +: get-remote-thread ( name -- thread ) + dup registered-remote-threads at [ ] [ thread ] ?if ; SYMBOL: local-node : handle-node-client ( -- ) deserialize - [ first2 get-process send ] [ stop-this-server ] if* ; + [ first2 get-remote-thread send ] [ stop-this-server ] if* ; : ( addrspec -- threaded-server ) binary @@ -40,26 +40,26 @@ SYMBOL: local-node : start-node ( port -- ) host-name over (start-node) ; -TUPLE: remote-process id node ; +TUPLE: remote-thread node id ; -C: remote-process +C: remote-thread : send-remote-message ( message node -- ) binary [ serialize ] with-client ; -M: remote-process send ( message thread -- ) +M: remote-thread send ( message thread -- ) [ id>> 2array ] [ node>> ] bi send-remote-message ; M: thread (serialize) ( obj -- ) - id>> local-node get-global + id>> [ local-node get-global ] dip (serialize) ; : stop-node ( node -- ) f swap send-remote-message ; [ - H{ } clone \ registered-processes set-global + H{ } clone \ registered-remote-threads set-global ] "remote-thread-registry" add-init-hook -- 2.34.1