• 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: Simon Strandgaard <email@hidden>
  • Date: Fri, 15 Jul 2005 08:34:29 +0200

On 7/15/05, Shaun Wexler <email@hidden> wrote:
> On Jul 14, 2005, at 12:36 PM, Simon Strandgaard wrote:
[snip]
> > 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++..
[snip]
>  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.

Hehe.. this is what I am doing.. :-)

pthread_mutex_t midi_incoming_mutex;
std::queue<MidiMessage> midi_incoming_queue;


in the midi_read_callback

pthread_mutex_lock(&midi_incoming_mutex);
int size = midi_incoming_queue.size();
midi_incoming_queue.push(message);
pthread_mutex_unlock(&midi_incoming_mutex);

if(size == 0) {
	[midi_dispatcher
		performSelectorOnMainThread:@selector(incomingMessage)
		withObject:nil
		waitUntilDone:NO
	];
}


Thanks otherwise, I got it solved really fast last night.. in less
than 30 minutes
I had gotten a similar answer from Nick. (very fast)

--
Simon Strandgaard
 _______________________________________________
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

References: 
 >C++ thread messaging cocoa thread (From: Simon Strandgaard <email@hidden>)
 >Re: C++ thread messaging cocoa thread (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Re: Trying to bind to NSTreeController
  • Next by Date: Re: Creating an XML document
  • Previous by thread: Re: C++ thread messaging cocoa thread
  • Next by thread: Displaying multiple NSView subclasses
  • Index(es):
    • Date
    • Thread