]> gitweb.factorcode.org Git - factor.git/commitdiff
not using message passing threads for modules
authorSam Anklesaria <sam@Tintin.local>
Tue, 4 Aug 2009 03:29:02 +0000 (22:29 -0500)
committerSam Anklesaria <sam@Tintin.local>
Tue, 4 Aug 2009 03:29:02 +0000 (22:29 -0500)
extra/modules/rpc-server/rpc-server-docs.factor
extra/modules/rpc-server/rpc-server.factor
extra/modules/rpc/rpc.factor
extra/modules/using/using-docs.factor

index fc2c2344dd01d839c88dfa05c71e1218b1e6b4f2..f1d4be446599eec0edcc9304d57122dca0d2b10b 100644 (file)
@@ -2,4 +2,4 @@ USING: help.syntax help.markup modules.rpc-server modules.using ;
 IN: modules.rpc-server
 HELP: service
 { $syntax "IN: my-vocab service" }
-{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } ;
\ No newline at end of file
+{ $description "Allows words defined in the vocabulary to be used as remote procedure calls by " { $link POSTPONE: USING*: } ;
\ No newline at end of file
index 7ac50ab61fd62afffdd4a28671fb10aea1b23f93..bafdc5533560ed6495c957c66156968192278a63 100644 (file)
@@ -1,35 +1,31 @@
 ! Copyright (C) 2009 Sam Anklesaria.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs concurrency.distributed
-concurrency.messaging continuations effects init kernel
-namespaces sequences sets threads vocabs vocabs.parser ;
+USING: accessors assocs combinators continuations effects
+io.encodings.binary io.servers.connection kernel namespaces
+sequences serialize sets threads vocabs vocabs.parser init ;
 IN: modules.rpc-server
+
 <PRIVATE
 TUPLE: rpc-request args vocabspec wordname ;
 SYMBOL: serving-vocabs serving-vocabs [ V{ } clone ] initialize
 
-: register-gets-thread ( -- )
-    [ receive [ data>> dup serving-vocabs get-global index
+: getter ( -- ) deserialize dup serving-vocabs get-global index
         [ vocab-words [ stack-effect ] { } assoc-map-as ]
-        [ \ no-vocab boa ] if
-    ] keep reply-synchronous 
-    t ] "get-words" spawn-server "gets-thread" swap register-process ;
+        [ \ no-vocab boa ] if serialize ;
 
-: register-does-thread ( -- )
-    [ receive [ data>> dup vocabspec>> serving-vocabs get-global index
+: doer ( -- ) deserialize dup vocabspec>> serving-vocabs get-global index
         [ [ args>> ] [ wordname>> ] [ vocabspec>> vocab-words ] tri at [ execute ] curry with-datastack ]
-        [ vocabspec>> \ no-vocab boa ] if
-    ] keep reply-synchronous
-    t ] "do-word" spawn-server "does-thread" swap register-process ;
-
-: register-loads-thread ( -- )
-    [ [ receive vocab ] keep reply-synchronous t ] "load-words" spawn-server "loads-thread" swap register-process ;
+        [ vocabspec>> \ no-vocab boa ] if serialize ;
 
 PRIVATE>
 SYNTAX: service current-vocab name>> serving-vocabs get-global adjoin ;
 
-[ 9012 start-node
-    register-gets-thread
-    register-does-thread
-    register-loads-thread
+[ [ binary <threaded-server>
+    "rpcs" >>name 9012 >>insecure
+    [ break deserialize {
+      { [ "getter" ] [ getter ] }
+      { [  "doer" ] [ doer ] }
+      { [ "loader" ] [ deserialize vocab serialize ] } 
+    } case ] >>handler
+    start-server ] in-thread drop
 ] "modules.rpc-server" add-init-hook
\ No newline at end of file
index 724a779f7e09cedb084c34c0bbf34f87d702e40f..75b5ef3fe56d01fcb1787f0925ee24c6122e7926 100644 (file)
@@ -1,24 +1,27 @@
 ! Copyright (C) 2009 Sam Anklesaria.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs concurrency.distributed
-concurrency.messaging fry generalizations io.sockets kernel
-locals namespaces parser sequences vocabs vocabs.parser words ;
+USING: accessors assocs fry generalizations io.encodings.binary
+io.sockets kernel locals namespaces parser sequences serialize
+vocabs vocabs.parser words tools.continuations io ;
 IN: modules.rpc
 
 TUPLE: rpc-request args vocabspec wordname ;
 
-: send-with-check ( message thread -- reply/* ) send-synchronous dup no-vocab? [ throw ] when ;
+: send-with-check ( message -- reply/* )
+    serialize flush deserialize dup no-vocab? [ throw ] when ;
 
 :: define-remote ( str effect addrspec vocabspec -- )
     str create-in effect [ in>> length ] [ out>> length ] bi
-    '[ _ narray vocabspec str rpc-request boa "does-thread" addrspec 9012 <inet> <remote-process> send-with-check _ firstn ]
+    '[ _ narray vocabspec str rpc-request boa addrspec 9012 <inet> binary
+    [ "doer" serialize serialize send-with-check ] with-client _ firstn ]
     effect define-declared ;
 
 :: remote-vocab ( addrspec vocabspec -- vocab )
    vocabspec "-remote" append dup vocab [ dup set-current-vocab
-     vocabspec "gets-thread" addrspec 9012 <inet> <remote-process> send-with-check
+     vocabspec addrspec 9012 <inet> binary [ "getter" serialize send-with-check ] with-client
      [ first2 addrspec vocabspec define-remote ] each
    ] unless ;
 
 : remote-load ( addr vocabspec -- voabspec ) [ swap
-    "loads-thread" swap 9012 <inet> <remote-process> send-synchronous ] keep [ dictionary get-global set-at ] keep ;
\ No newline at end of file
+    9012 <inet> binary [ "loader" serialize serialize flush deserialize ] with-client ] keep
+    [ dictionary get-global set-at ] keep ;
\ No newline at end of file
index f3c25f920134431f3f7cb35beddf0c54bf4d7c25..0f67f2b0eeb73153e6927ac99f6386d0d980d642 100644 (file)
@@ -8,5 +8,4 @@ ABOUT: { "modules.using" "use" }
 
 HELP: USING*:
 { $syntax "USING: rpc-server::module fetch-sever:module { module qualified-name } { module => word ... } { qualified-module } { module EXCEPT word ... } { module word => importname } ;" }
-{ $description "Adds vocabularies to the search path. Vocabularies can be loaded off a server or called as an rpc if preceded by a valid hostname. Bracketed pairs facilitate all types of qualified imports on both remote and local modules." }
-"To use the 'USING*:' without explicitly importing modules.using first, add '\"modules.using\" require' to your .factor-boot-rc" ;
\ No newline at end of file
+{ $description "Adds vocabularies to the search path. Vocabularies can be loaded off a server or called as an rpc if preceded by a valid hostname. Bracketed pairs facilitate all types of qualified imports on both remote and local modules." } ;
\ No newline at end of file