0

I was testing performSelector:onThread:withObject:waitUntilDone: for inter-thread communication as recommended by Matt Ghallagher's tutorial. Turns out that it is extremely slow, and pretty much no good for real time audio applications. Any suggestions?

abbood
  • 23,101
  • 16
  • 132
  • 246

1 Answers1

0

On the main thread:

AnyClass myObject;

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   // do asynchronous work
   // environment objects and variables will be available
   [myObject doSomething];
});

It really does not get any simpler than that...

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • I'm not sure how this addresses my question. I'm talking about a specific thread asking for a method to be executed on another specific thread and sending it a parameter.. in your case you are just asking myobject to do something on another randomly generated thread.. or am i wrong? – abbood Nov 24 '12 at 15:54
  • What do you mean by "randomly generated"? I recommend reading up on GCD, as it will reduce the amount of code you use dramatically. You can specify your own created queue (instead of the global queue) as well, but in many cases this is not necessary by design. – Mundi Nov 24 '12 at 17:44