Re: C++ thread messaging cocoa thread
Re: C++ thread messaging cocoa thread
- Subject: Re: C++ thread messaging cocoa thread
- From: Shaun Wexler <email@hidden>
- Date: Thu, 14 Jul 2005 15:53:10 -0700
On Jul 14, 2005, at 12:36 PM, Simon Strandgaard wrote:
I have made a cocoa GUI, which I want to be controllable
from my MIDI keyboard.
The midi_read_callback is in a thread that doesn't have a
NSAutoreleasepool, so if I invoke any methods on the
GUI instance then I get warnings like this.
_NSAutoreleaseNoPool(): Object 0xa2e89ccc of class NSCFString
autoreleased with no pool in place - just leaking
Correct me if I am wrong; I think that the only option I have
is to add a NSPort to the cocoa runloop, which is signaled
from C++..
how to refer from C++ to a NSPort?
should I use CFMessagePortCreateRemote ?
From a realtime thread, you should create invocations and add them
to an atomic FIFO queue, and signal the main thread using a mach
semaphore. Wrap the signaling with an atomic flag so it is only sent
once per main thread activation, and have your main thread process
the entire queue each time.
You can also use -
performSelectorOnMainThread:withObject:waitUntilDone: (recommended
for testing purposes only, since it has extra overhead that you may
not want).
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden