[LAD] Inter thread Communication: Design Approach

Florian Paul Schmidt mista.tapas at gmx.net
Fri Sep 2 17:29:16 UTC 2011

On 09/02/2011 05:13 PM, David Robillard wrote:
> On Fri, 2011-09-02 at 10:36 +0200, Florian Paul Schmidt wrote:
>> On 09/01/2011 10:37 PM, Harry van Haaren wrote:
> [...]
>> Coupled with a poor man's garbage collection scheme using
>> boost::shared_ptr's this was a quite quick way to hack up jass. There's
>> no need to introduce new types if you want to do something new. Actually
>> there's only exactly one type that gets passed through the command
>> ringbuffer and that is boost::function<void(void)>. See e.g.
> Careful doing this, note that dropping the last shared_ptr to an object
> is NOT real-time (it calls delete), even if destroying the actual object
> is.

yeah. that's why there's a extra reference stored in a list whenever an 
(disposable) object is created.. This list is traversed periodically 
from within the GUI thread to check whether any one's object refcount 
has dropped to 1 (not 0) and only then is that last reference removed 
from the list causing the ref count to go to 0 and the object finally 
being deleted (in the GUI thread)..

Note that all objects the engine manages in jass are stored in 
disposable<T> which forces them to be allocated through the factory 
function that always stores an extra reference in the list..


More information about the Linux-audio-dev mailing list