[Ecls-list] Mailbox object

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Fri Apr 6 23:02:28 UTC 2012


I have implemented a first version of mailboxes. It is still in very much
alpha stage, like the rest of the code discussed during these weeks, but a
simple example seems to work

(defun test-mailbox (nwriters &optional (messages 1000))
  (declare (optimize (safety 0)))
  (let* ((barrier (mp:make-barrier t :name 13))
 (writer-messages (the fixnum (round messages nwriters)))
 (total-messages (the fixnum (* writer-messages nwriters)))
 (mailbox (mp:make-mailbox))
 (reader (mp:process-run-function
  :reader
  #'(lambda ()
      (mp:barrier-wait barrier)
      (time
       (loop for i of-type fixnum from 0 below total-messages
  do (mp:mailbox-read mailbox))))))
 (writers (loop for i from 0 below nwriters
     do (mp:process-run-function
 i
 #'(lambda ()
     (mp:barrier-wait barrier)
     (loop for i of-type fixnum from 0 below writer-messages
 do (mp:mailbox-send mailbox i)))))))
    (mp:barrier-unblock barrier :disable t)
    (mp:process-join reader)))

Figures are not that bad either, are they?

> (test-mailbox 10 100000)

real time : 0.319 secs
run time  : 0.062 secs
gc count  : 1 times
consed    : 352 bytes
NIL
> (test-mailbox 1 100000)

real time : 0.018 secs
run time  : 0.027 secs
gc count  : 1 times
consed    : 208 bytes
NIL

-- 
Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28006 (Spain)
http://juanjose.garciaripoll.googlepages.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ecl-devel/attachments/20120407/3c12f6e2/attachment.html>


More information about the ecl-devel mailing list