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<br clear="all"><div><br></div><div><div>(defun test-mailbox (nwriters &optional (messages 1000))</div>
<div> (declare (optimize (safety 0)))</div><div> (let* ((barrier (mp:make-barrier t :name 13))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (writer-messages (the fixnum (round messages nwriters)))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (total-messages (the fixnum (* writer-messages nwriters)))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (mailbox (mp:make-mailbox))</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (reader (mp:process-run-function</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> :reader</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> #'(lambda ()</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (mp:barrier-wait barrier)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (time</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (loop for i of-type fixnum from 0 below total-messages</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> do (mp:mailbox-read mailbox))))))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (writers (loop for i from 0 below nwriters</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> do (mp:process-run-function</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> i</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> #'(lambda ()</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span> (mp:barrier-wait barrier)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (loop for i of-type fixnum from 0 below writer-messages</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>do (mp:mailbox-send mailbox i)))))))</div><div> (mp:barrier-unblock barrier :disable t)</div><div> (mp:process-join reader)))</div><div><br></div>
<div>Figures are not that bad either, are they?</div><div><br></div><div><div>> (test-mailbox 10 100000)</div><div><br></div><div>real time : 0.319 secs</div><div>run time : 0.062 secs</div><div>gc count : 1 times</div>
<div>consed : 352 bytes</div><div>NIL</div><div>> (test-mailbox 1 100000)</div><div><br></div><div>real time : 0.018 secs</div><div>run time : 0.027 secs</div><div>gc count : 1 times</div><div>consed : 208 bytes</div>
<div>NIL</div></div></div><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>