Thread Safety & Object Deletion


    Feb 24 2006 | 2:49 am
    Hey... I have an external, which is, for the most part, thread safe. My one remaining concern is this:
    In overdrive, will my object ever have its delete (free) method called by one thread while other threads are still inside performing calculations and such? If so, is there any commonly-accepted way in an external to tell said still-busy thread to abort ASAP?
    Thanks
    -Alex

    • Mar 15 2006 | 5:40 am
      Hi Alex - I didn't see an answer to your Q, so sorry if this is stuff you already have figured out.
      I believe the free method will only ever get called from the main thread. I'm sure someone will correct me if I'm wrong. That said, it is unlikely but possible for the object to be processing something in the scheduler or perform threads and be deleted at the same time.
      Ben
    • Mar 15 2006 | 11:04 am
      On 15-Mar-2006, at 6:40, Ben Nevile wrote: > I believe the free method will only ever get called from the main > thread.
      Unless I'm very much mistaken, an object's instantiation method is guaranteed to be called from the main thread *and can make assumptions based on that premise*. (In the old days this included things like NewPointer() and NewHandle() being safe).
      Since a free method is almost necessarily predicated on the same assumptions that the instantiation method is (e.g., freeing up memory allocated with NewPointer() or NewHandle() or whatever), it would be highly uncool to call xxx_free() from anywhere else.
      IOW: Boyohboy, I sure hope you're right!
      -- P
      -------------- http://www.bek.no/~pcastine/Litter/ ------------- Peter Castine | +--> Litter Power & Litter Bundle for Jitter |.................................................... p@castine.de | iCE: Sequencing, Recording, and Interface Building pcastine@gmx.net | for Max/MSP pcastine@bek.no | http://www.dspaudio.com/ Extremely cool 4-15@kagi.com |.................................................... | home|chez nous|wir|i nostri http://www.castine.de/