Re: Threading Question
Re: Threading Question
- Subject: Re: Threading Question
- From: Michael Tyson <email@hidden>
- Date: Mon, 13 Feb 2012 14:36:19 +0100
I thought I'd share my revised system, which is relatively versatile. It uses function pointers along with some 'opaque' parameters within each message, so when a message is dispatched to the realtime thread, you can pass in an arbitrary message handler.
https://gist.github.com/1817010
Fun!
The essentials:
typedef long (*TPAudioControllerMessageHandler) (TPAudioController *THIS, long parameter1, long parameter2, long parameter3, void *ioOpaquePtr);
- (void)performAsynchronousMessageExchangeWithHandler:(TPAudioControllerMessageHandler)handler parameter1:(long)parameter1 parameter2:(long)parameter2 parameter3:(long)parameter3 ioOpaquePtr:(void*)ioOpaquePtr responseBlock:(void (^)(struct _message_t message, long response))responseBlock;
- (long)performSynchronousMessageExchangeWithHandler:(TPAudioControllerMessageHandler)handler parameter1:(long)parameter1 parameter2:(long)parameter2 parameter3:(long)parameter3 ioOpaquePtr:(void*)ioOpaquePtr;
On 13 Feb 2012, at 10:43, Michael Tyson wrote:
> Hopefully I've managed to fix the dumb that Michael pointed out in TPCircularBuffer =)
>
> Incidentally, this is how I'm using it to avoid locking from my realtime core audio thread. It uses two ring buffers, one that contains messages for the realtime thread to process, and one that contains responses from the realtime thread, both of which are polled by their respective threads. Two utility methods provide synchronous and asynchronous (with a block argument for reply processing) message-response exchange.
>
> https://gist.github.com/1815496
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden