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

psmith at common-lisp.net psmith at common-lisp.net
Mon Jan 29 02:35:59 UTC 2007


Author: psmith
Date: Sun Jan 28 21:35:58 2007
New Revision: 55

Modified:
   branches/home/psmith/restructure/run-yarpc-client.lisp
   branches/home/psmith/restructure/run-yarpc.lisp
   branches/home/psmith/restructure/src/buffer/buffer.lisp
   branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp
   branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp
Log:
large packet support first working version

Modified: branches/home/psmith/restructure/run-yarpc-client.lisp
==============================================================================
--- branches/home/psmith/restructure/run-yarpc-client.lisp	(original)
+++ branches/home/psmith/restructure/run-yarpc-client.lisp	Sun Jan 28 21:35:58 2007
@@ -1,4 +1,4 @@
-;(push :nio-debug *features*)
+(push :nio-debug *features*)
 (require :asdf)
 (require :nio-yarpc)
 

Modified: branches/home/psmith/restructure/run-yarpc.lisp
==============================================================================
--- branches/home/psmith/restructure/run-yarpc.lisp	(original)
+++ branches/home/psmith/restructure/run-yarpc.lisp	Sun Jan 28 21:35:58 2007
@@ -1,6 +1,6 @@
 ;Runs a multithreaded system with an IO thread dealing with IO only and a 'job'  thread taking and executing jobs
 
-;(push :nio-debug *features*)
+(push :nio-debug *features*)
 (require :asdf)
 (require :nio-yarpc)
 

Modified: branches/home/psmith/restructure/src/buffer/buffer.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/buffer.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/buffer.lisp	Sun Jan 28 21:35:58 2007
@@ -175,14 +175,25 @@
     (inc-position bb 4)
     val))
 
+;write an 8 bit value and up date position in buffer
 (defmethod bytebuffer-write-8 ((bb byte-buffer) value)
   (setf (cffi:mem-ref (buffer-buf bb) :unsigned-char (buffer-position bb)) value)
   (inc-position bb 1))
 
+;write a 32 bit value and up date position in buffer
 (defmethod bytebuffer-write-32 ((bb byte-buffer) value)
   (setf (cffi:mem-ref (buffer-buf bb) :unsigned-int (buffer-position bb)) value)
   (inc-position bb 4))
 
+;insert an 8 bit value
+(defmethod bytebuffer-insert-8 ((bb byte-buffer) value byte-position)
+  (setf (cffi:mem-ref (buffer-buf bb) :unsigned-char byte-position) value))
+
+;insert a 32 bit value
+(defmethod bytebuffer-insert-32 ((bb byte-buffer) value byte-position)
+  (setf (cffi:mem-ref (buffer-buf bb) :unsigned-int byte-position) value))
+
+
 
 
 ;; Write bytes from vector vec to bytebuffer

Modified: branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp
==============================================================================
--- branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp	(original)
+++ branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp	Sun Jan 28 21:35:58 2007
@@ -29,6 +29,7 @@
 	    (:export
 	     byte-buffer free-buffer remaining inc-position get-string buffer-buf 
 	     bytebuffer-write-vector bytebuffer-write-string 
-	     bytebuffer-read-vector bytebuffer-read-string bytebuffer-read-8 bytebuffer-read-32
+	     bytebuffer-read-vector bytebuffer-read-string 
+	     bytebuffer-read-8 bytebuffer-read-32 bytebuffer-write-8 bytebuffer-write-32 bytebuffer-insert-8 bytebuffer-insert-32
 	     flip unflip clear buffer-position copy-buffer buffer-capacity
 	     ))

Modified: branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp
==============================================================================
--- branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp	(original)
+++ branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp	Sun Jan 28 21:35:58 2007
@@ -35,8 +35,14 @@
 (defun yarpc-packet-factory ()
   (make-instance 'yarpc-packet-factory))     
 
-(defconstant CALL-METHOD-PACKET-ID #x0)
-(defconstant METHOD-RESPONSE-PACKET-ID #x1)
+(defconstant +CALL-METHOD-PACKET-ID+ #x0)
+(defconstant +METHOD-RESPONSE-PACKET-ID+ #x1)
+
+(defconstant +PACKET-ID-SIZE+ 1)
+(defconstant +PACKET-LENGTH-SIZE+ 4)
+
+(defconstant +yarpc-packet-header-size+
+  (+ +PACKET-ID-SIZE+ +PACKET-LENGTH-SIZE+))
 
 (defmethod get-packet ((pf yarpc-packet-factory) buf)
   (flip buf)
@@ -56,13 +62,6 @@
 
 (defclass call-method-packet (packet)((call-string :initarg :call-string
                                             :accessor call-string)))
-
-(defconstant +PACKET-ID-SIZE+ 1)
-(defconstant +PACKET-LENGTH-SIZE+ 4)
-
-(defconstant +yarpc-packet-header-size+
-  (+ +PACKET-ID-SIZE+ +PACKET-LENGTH-SIZE+))
-
 (defun call-method-packet (call-string)
   (make-instance 'call-method-packet :call-string call-string))
 
@@ -70,11 +69,13 @@
   (format stream "#<CALL-METHOD-PACKET ~A >" (call-string packet)))
 
 (defmethod write-bytes((packet call-method-packet) buf)
-#+nio-debug  (format-log t "yarpc-packet-factory:write-bytes - writing ~A to ~A~%" packet buf)
-  (nio-buffer:bytebuffer-write-vector buf #(#x0))
+  #+nio-debug  (format-log t "yarpc-packet-factory:write-bytes(call-method-packet) - writing ~%~A to ~%~A~%" packet buf)
+  (nio-buffer:bytebuffer-write-8 buf +CALL-METHOD-PACKET-ID+)
+  (nio-buffer:bytebuffer-write-32 buf 0) ; come back and write length later
   (nio-buffer:bytebuffer-write-string buf (call-string packet))
-#+nio-debug    (format-log t "yarpc-packet-factory:write-bytes - written ~A~%" buf)  
-)
+  (nio-buffer:bytebuffer-insert-32 buf (buffer-position buf) 1)
+  #+nio-debug    (format-log t "yarpc-packet-factory:write-bytes(call-method-packet) - written ~%~A ~%" buf)  
+  )
   
 
 (defclass method-response-packet (packet)
@@ -89,7 +90,9 @@
 
 (defmethod write-bytes((packet method-response-packet) buf)
 #+nio-debug    (format-log t "yarpc-packet-factory:write-bytes - writing ~A to ~A~%" packet buf)
-  (nio-buffer:bytebuffer-write-vector buf #(#x1))
+  (nio-buffer:bytebuffer-write-8 buf +METHOD-RESPONSE-PACKET-ID+)
+  (nio-buffer:bytebuffer-write-32 buf 0) ; come back and write length later
   (nio-buffer:bytebuffer-write-string buf (write-to-string (response packet)))
+  (nio-buffer:bytebuffer-insert-32 buf (buffer-position buf) 1)
 #+nio-debug    (format-log t "yarpc-packet-factory:write-bytes - written ~A~%" buf)  
 )



More information about the Nio-cvs mailing list