Re: Cocoa multithreading in C (terrible idea, isn't it?)
Re: Cocoa multithreading in C (terrible idea, isn't it?)
- Subject: Re: Cocoa multithreading in C (terrible idea, isn't it?)
- From: John Stiles <email@hidden>
- Date: Tue, 20 Dec 2005 15:13:32 -0800
You can't process events on a thread other than the main thread. As
you've found, it will not work and can die in a variety of ways.
With Cocoa/AppKit (and with most UIs), if something isn't explicitly
documented as being thread-safe, you must do it on the main thread.
On Dec 20, 2005, at 3:07 PM, Christos Papachristou wrote:
Hi,
I am a complete newbie on Cocoa and objective-C, coming from a UNIX/
C background. I am currently trying to create a wrapper c library
around GLUT that will display on Aqua or X11. In X11 everything
works as expected. However, using the Cocoa GLUT Framework I
stumbled into issues that are not of my field. The problem is as
follows:
I want my application to run multithreaded. I have implemented all
thread interfaces: pthreads, Cocoa and Carbon, and initialized the
GLUT display system in the launched threads. In all cases, the
GlutWindow:NSApplication Object does not get any events. The event
handler thread of GLUT runs normaly. I have checked many
configurations, in one of them, the GlutWindow:NSApplication is
created before the creation of the thread, and the window drawing
routines inside the thread. In this case, the same statements
while ((event = [NSApp nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate
dateWithTimeIntervalSinceNow:
0.01]
inMode:NSEventTrackingRunLoopMode
// inMode:NSDefaultRunLoopMode
// inMode:NSModalPanelRunLoopMode
// inMode:NSConnectionReplyMode
dequeue:YES])) {
[NSApp sendEvent:event];
}
called in the launched thread have no effect, whereas in the
primary thread they do make the event handlers of the lauched
thread to respond normaly.
In al cases the created windows appear and can be moved, yet they
do not respond to resize and redraw events caused by mouse clicks.
Also the spin wheel appears and the proccessor load goes crazy.
I am starting to get a hunch about OO programming but I am far from
any really useful knowledge. Apart from someone telling me some
solution, could you also explain me what is happening and why?
Thank you in advance,
A desperate console/C Programmer,
Christos Papachristou
PowerBook G4-Mac OS X 10.4.3
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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