[nio-cvs] r45 - in branches/home/psmith/restructure: . src/protocol/yarpc

psmith at common-lisp.net psmith at common-lisp.net
Fri Jan 19 02:07:22 UTC 2007


Author: psmith
Date: Thu Jan 18 21:07:22 2007
New Revision: 45

Modified:
   branches/home/psmith/restructure/TODO
   branches/home/psmith/restructure/run-yarpc.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
Log:
Allowed yarpc server to do RPC calls inline if configured so

Modified: branches/home/psmith/restructure/TODO
==============================================================================
--- branches/home/psmith/restructure/TODO	(original)
+++ branches/home/psmith/restructure/TODO	Thu Jan 18 21:07:22 2007
@@ -12,3 +12,7 @@
 Create UDP server
 
 Create RPC server / client
+
+Non blocking connects
+
+Allow large packets

Modified: branches/home/psmith/restructure/run-yarpc.lisp
==============================================================================
--- branches/home/psmith/restructure/run-yarpc.lisp	(original)
+++ branches/home/psmith/restructure/run-yarpc.lisp	Thu Jan 18 21:07:22 2007
@@ -1,11 +1,11 @@
+;Runs a multithreaded system with an IO thread dealing with IO only and a 'job'  thread taking and executing jobs
+
 ;(push :nio-debug *features*)
 (require :asdf)
 (require :nio-yarpc)
 
+(setf nio-yarpc:+process-jobs-inline+ nil)
 (sb-thread:make-thread #'(lambda()(nio:start-server 'identity 'identity 'nio-yarpc:yarpc-state-machine :host "127.0.0.1")) :name "nio-server")
 (loop
     ;;block waiting for jobs
-    (format t "~A Server toplevel waiting for job~%" (nio-compat:get-readable-time))
-    (destructuring-bind (job result-queue) (nio-compat:take nio-yarpc:job-queue)
-      (format t "~A Server received job ~A~%" (nio-compat:get-readable-time) job)
-      (nio-compat:add result-queue (nio-yarpc:execute-call job))))
+     (nio-yarpc:run-job))

Modified: branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/nio-yarpc-package.lisp	Thu Jan 18 21:07:22 2007
@@ -32,7 +32,7 @@
              yarpc-state-machine-factory get-packet-factory 
 
 	     ;; yarpc-state-machine
-	     yarpc-state-machine job-queue
+	     yarpc-state-machine job-queue run-job +process-jobs-inline+
 	     ;to be moved
 	     test-rpc test-rpc-list test-rpc-string execute-call
 	     

Modified: branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/yarpc-state-machine.lisp	Thu Jan 18 21:07:22 2007
@@ -1,4 +1,4 @@
-#|
+\#|
 Copyright (c) 2007
 All rights reserved.
 
@@ -52,6 +52,19 @@
 (defconstant STATE-INITIALISED 0)
 (defconstant STATE-SEND-RESPONSE 1)
 
+
+(defparameter +process-jobs-inline+ t
+  "Set this to make the NIO thread process the RPC calls - warning the procedure should not block!")
+
+
+
+(defun run-job(&key (wait-on-job-pdw t))
+  (format t "~A Server toplevel waiting for job~%" (nio-compat:get-readable-time))
+  (destructuring-bind (job result-queue) (nio-compat:take nio-yarpc:job-queue :blocking-call wait-on-job-pdw)
+    (format t "~A Server received job ~A~%" (nio-compat:get-readable-time) job)
+    (nio-compat:add result-queue (nio-yarpc:execute-call job))))
+
+
 (defmethod process-outgoing-packet((sm yarpc-state-machine))
   (format t "yarpc-state-machine: process-outgoing-packet called, polling the results-queue ~%")
   (let ((result (nio-compat:take (result-queue sm) :blocking-call nil)))
@@ -63,7 +76,8 @@
 (defmethod process-incoming-packet ((sm yarpc-state-machine) (call call-method-packet))
   (assert (eql (state sm) STATE-INITIALISED))
   (format t "yarpc-state-machine:process-incoming-packet called :sm ~A :packet ~A~%" sm call)
-  (nio-compat:add job-queue (list (call-string call) (result-queue sm))))
+  (nio-compat:add job-queue (list (call-string call) (result-queue sm)))
+  (when +process-jobs-inline+ (run-job :wait-on-job-pdw nil)))
 
 
 



More information about the Nio-cvs mailing list