Lisp HUG Maillist Archive

execute-with-interface requirements

Does anyone know if one must use execute-with-interface to access slots created with define-interface?

(define-interface name superclasses SLOTS &rest options)

I'm trying to peek inside of an interface to see if there is work to be done from another process (part of the wake function for that other process). That works in CLIM but now that I'm trying to rejigger things for CAPI I wonder if I have to change the approach.

(in other words, my interface has a work queue, but that work queue is processed by a thread other than the one CAPI thread on a Mac (in CLIM it got processed in that CLIM thread so no worries). So I need that thread to sleep when the queue is empty, and the wake function checks to see if there is something waiting. The work queue lives in the interface because the interface adds work to it based on user activity. Given all the changes to MP since LW5, I wonder if maybe I shouldn't just reimplement with a mailbox or some such; I avoided this for cross-implementation purposes before but….)

Thanks!


Re: execute-with-interface requirements

>>>>> On Tue, 08 Nov 2011 17:00:37 -0500, Bradford W Miller said:
> 
> Does anyone know if one must use execute-with-interface to access slots
> created with define-interface?
> 
> (define-interface name superclasses SLOTS &rest options)
> 
> I'm trying to peek inside of an interface to see if there is work to be done
> from another process (part of the wake function for that other
> process). That works in CLIM but now that I'm trying to rejigger things for
> CAPI I wonder if I have to change the approach.

Slots you have added with define-interface are normal defclass slots, so are
safe to access without execute-with-interface.  However, you might have to
deal with synchronization issues if concurrent threads access a slot more than
once or access more than one slot.


> (in other words, my interface has a work queue, but that work queue is
> processed by a thread other than the one CAPI thread on a Mac (in CLIM it
> got processed in that CLIM thread so no worries). So I need that thread to
> sleep when the queue is empty, and the wake function checks to see if there
> is something waiting. The work queue lives in the interface because the
> interface adds work to it based on user activity. Given all the changes to
> MP since LW5, I wonder if maybe I shouldn't just reimplement with a mailbox
> or some such; I avoided this for cross-implementation purposes before
> butÂ….)

Using a mailbox is the best option for a FIFO queue because it will handle all
of the synchronization issues.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/


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