Re: LW 4.2 on Linux, multiprocessing w/ capi
On Friday 22 May 2009 1:13:27 pm gregm32768@comcast.net wrote:
>
> I have a capi app that receives a stream of UDP packets, each of which
...
I'm not sure if I understood your problem correctly, but here's a thought:
Use mailboxes and allow the display updater to run "asynchronously" at whatever speed it needs to. The timer would simply send a blip to the mailbox, the updater would read the mailbox when it gets a chance. Here's an incomplete snippet of code from my current project that does this. The inner loop of updater-process ("dumping") dumps blips on the floor if the updater fell behind and doesn't wish to bother updating stale info - kind of like how Microsoft Word worked in the days of 8086's and 286's (you could type more quickly than it could refresh and text would appear on the screen in lumps).
pt
(defvar *updater* nil)
(defvar *updater-mbox* nil)
(defun start-updater ()
(unless +debug+
(setq *updater-mbox* (mp:make-mailbox))
(setq *updater* (mp:process-run-function "Updater"
(list :mailbox *updater-mbox*)
#'updater-process
*standard-output*))))
(defun kill-updater ()
(mp:process-kill *updater*))
(defun updater-process (stream)
(declare (ignorable stream))
(let ((mb (mp:process-mailbox mp:*current-process*)))
(loop
(let ((intf (mp:mailbox-read mb)))
(capi:execute-with-interface intf 'exec-regenerate intf)
(let ((intf (mp:mailbox-peek mb)))
(when intf
(loop until (mp:mailbox-empty-p mb)
do
;(format stream "dumping~%")
(mp:mailbox-read mb))
(capi:execute-with-interface intf 'exec-regenerate intf)))))))