• 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: C++ thread messaging cocoa thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: C++ thread messaging cocoa thread
      • From: Simon Strandgaard <email@hidden>
References: 
 >C++ thread messaging cocoa thread (From: Simon Strandgaard <email@hidden>)

  • Prev by Date: Get a selector type (SEL) from a string dinamically
  • Next by Date: Re: Get a selector type (SEL) from a string dinamically
  • Previous by thread: Re: C++ thread messaging cocoa thread
  • Next by thread: Re: C++ thread messaging cocoa thread
  • Index(es):
    • Date
    • Thread