Changeset 56 for branches/home
- Timestamp:
- 01/29/07 04:27:18 (18 years ago)
- Location:
- branches/home/psmith/restructure/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/home/psmith/restructure/src/buffer/buffer.lisp ¶
r55 r56 152 152 byte-buffer)) 153 153 154 (defmethod compact((byte-buffer byte-buffer)) 155 :documentation "copy remaining bytes to the beginning of this buffer and set position to number of bytes copied (ready for a new put" 156 (with-slots (buf position limit) byte-buffer 157 (let ((remaining (remaining byte-buffer))) 158 (%memcpy buf (cffi:make-pointer (+ (cffi:pointer-address buf) position)) remaining) 159 (setf position remaining)))) 160 154 161 ;reads bytes from byte-buffer and returns a vector (unsigned-byte 8) 155 162 (defmethod bytebuffer-read-vector((bb byte-buffer) &optional (num-bytes-to-read (remaining bb))) … … 282 289 (format t "Mybuf (after r/w 32bit): ~A~%" mybuf) 283 290 284 291 (setf (buffer-position mybuf) 11) 292 293 (compact mybuf) 294 (format t "Mybuf (after compact): ~A~%" mybuf) 295 (assert (eql (buffer-position mybuf) (- 32 11))) 296 (flip mybuf) 297 (format t "Mybuf (flip): ~A~%" mybuf) 298 (assert (eql (bytebuffer-read-32 mybuf) 2147483649)) 285 299 286 300 (free-buffer mybuf) -
TabularUnified branches/home/psmith/restructure/src/buffer/nio-buffer-package.lisp ¶
r55 r56 32 32 bytebuffer-read-vector bytebuffer-read-string 33 33 bytebuffer-read-8 bytebuffer-read-32 bytebuffer-write-8 bytebuffer-write-32 bytebuffer-insert-8 bytebuffer-insert-32 34 flip unflip clear buffer-position copy-buffer buffer-capacity 34 flip unflip clear buffer-position copy-buffer buffer-capacity compact 35 35 )) -
TabularUnified branches/home/psmith/restructure/src/protocol/yarpc/yarpc-packet-factory.lisp ¶
r55 r56 51 51 (packet-length (bytebuffer-read-32 buf))) 52 52 (if (<= (- packet-length +yarpc-packet-header-size+) (remaining buf)) ;is the whole packet available in the buffer? 53 (ecase packet-id 54 (0 (progn (format-log t "yarpc-packet-factory:get-packet - got CALL-METHOD-PACKET-ID~%") (call-method-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+))))) 55 (1 (progn (format-log t "yarpc-packet-factory:get-packet - got METHOD-RESPONSE-PACKET-ID~%") (method-response-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+)))))) 53 (let ((ret-packet (ecase packet-id 54 (0 (progn (format-log t "yarpc-packet-factory:get-packet - got CALL-METHOD-PACKET-ID~%") (call-method-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+))))) 55 (1 (progn (format-log t "yarpc-packet-factory:get-packet - got METHOD-RESPONSE-PACKET-ID~%") (method-response-packet (bytebuffer-read-string buf (- packet-length +yarpc-packet-header-size+)))))))) 56 (compact buf) 57 #+nio-debug (format-log t "yarpc-packet-factory:get-packet - after compact ~%~A~%" buf) 58 #+nio-debug (format-log t "yarpc-packet-factory:get-packet - retuirning packet ~A~%" ret-packet) 59 ret-packet) 60 ;Failed to read a whole packet unflip and check size 56 61 (let ((buffer-capacity (buffer-capacity buf))) 57 ;Failed to read a whole packet unflip and check size58 62 (unflip buf) 59 63 (if (> packet-length buffer-capacity) (error 'buffer-too-small-error :recommended-size packet-length)))))))
Note: See TracChangeset
for help on using the changeset viewer.