• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Threading Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Re: Threading Question (From: Morgan Packard <email@hidden>)
 >Re: Threading Question (From: Kyle Sluder <email@hidden>)
 >Re: Threading Question (From: Michael Tyson <email@hidden>)
 >RE: Threading Question (From: email@hidden)
 >Re: Threading Question (From: Morgan Packard <email@hidden>)
 >Re: Threading Question (From: Michael Tyson <email@hidden>)

  • Prev by Date: Re: Threading Question
  • Next by Date: RE: Bad access with reference within mixer callback
  • Previous by thread: Re: Threading Question
  • Next by thread: RE: Threading Question
  • Index(es):
    • Date
    • Thread