Lisp HUG Maillist Archive

Mailbox Reader Process?

Hi,

Does anyone know what the purpose is for the mailbox-reader-process? I get the impression that this may be left over from ancient legacy code. It is documented as a function in the MP section of the Lispworks Reference Manual, but no description of its use.

There is a lock in each mailbox too, but I assume, perhaps incorrectly, that it is used to prevent conflicts between readers / writers on the internal queue, since each read or write manipulating the queue must occur atomically to keep the queue state consistent. But surely, the MP system isn't asked to switch to the reader process for reading from a mailbox... eh?

David McClain
Chief Technical Officer
Refined Audiometrics Laboratory
4391 N. Camino Ferreo
Tucson, AZĀ  85750

email: dbm@refined-audiometrics.com
phone: 1.520.390.3995
web: http://www.refined-audiometrics.com


:local-buffer causes exception, :once doesn't

I hope someone will be able to explain this. This is with LW 5.0.2.

In the following example, if I use :draw-pinboard-objects :once, it 
works fine, if I use :local-buffer, which I think I'd prefer, I get the 
following error:

Error: Exception C0000005 [flags 0] at 20FBBCC1 {inside #<Function 
INVALIDATE-RECT 20FBBBA2>}
eax 77D4B5F5 ebx        1 ecx      306 edx   8E03D8
esp 215ADA34 ebp 215ADA48 esi       56 edi 20FE2C6F
   1 (abort) Return to level 0.
   2 Return to top loop level 0.

Type :b for backtrace, :c <option number> to proceed,  or :? for other 
options

(capi:define-interface test-interface ()
   ((display-scale :accessor display-scale :initform 2))
   (:layouts
    (test-pb
     capi:pinboard-layout
     '()
     :accessor test-pb
     :background :white
;;; :local-buffer doesn't work - :once does work
     :draw-pinboard-objects :local-buffer
;    :draw-pinboard-objects :once
     :visible-min-width 300
     :visible-min-height 300)
    (main-layout
     capi:row-layout
     '(test-pb)))
   (:default-initargs
    :layout 'main-layout
    :best-height 300
    :best-width 300))

(defun test (d)
     (dotimes (i 10)
       (test-add-square (make-instance 'square :x (* 40 (1+ i)) :y 40) 
(test-pb d))))

(defun test-add-square (sq pinboard)
   (capi:manipulate-pinboard pinboard sq :add-top))

(defclass square (capi:pinboard-object)
   ((foreground :accessor foreground :initform nil :initarg :foreground))
   (:default-initargs
    :visible-min-width 30
    :visible-min-height 30))

(defmethod capi:draw-pinboard-object (pinboard (square square) &key)
   (capi:with-geometry square
     (gp:draw-rectangle pinboard
                        capi:%x% capi:%y%
                          capi:%width%
                          capi:%height%)))

To try it do:
 > (setf d (capi:display (make-instance 'test-interface)))
 > (test d)

Mitch


Re: Mailbox Reader Process?

Hello David,

| Does anyone know what the purpose is for the mailbox-reader-process? I
| get the impression that this may be left over from ancient legacy code.
| It is documented as a function in the MP section of the Lispworks
| Reference Manual, but no description of its use.

I believe that mailbox-reader-process is valuable for mail boxes created
explicitly. FWIW, I used to run reports in a dedicated process:

(defun ensure-reports-mailbox ()
  (unless %reports-mailbox%
    (setq %reports-mailbox% (mp:make-mailbox)))
  (unless (and (mp:process-alive-p (mp:mailbox-reader-process
                                                     %reports-mailbox%))
                    (equal (mp:process-name (mp:mailbox-reader-process
                                %reports-mailbox%))
                      #1="Reports runner"))
    (setf (mp:mailbox-reader-process %reports-mailbox%)
          (let ((mp:*process-initial-bindings*
                    (acons '*acroview-conversation* nil
                               mp:*process-initial-bindings*)))
            ;; Ensure per thread conversation handle
            (mp:process-run-function #1# (list :mailbox %reports-mailbox%)
                                     'reports-runner))))
  %reports-mailbox%)

And then

   (mp:mailbox-send (ensure-reports-mailbox) <thing>)
--
Sincerely,
Dmitriy Ivanov
lisp.ystok.ru


Updated at: 2020-12-10 08:44 UTC