• 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
Cocoa multithreading in C (terrible idea, isn't it?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cocoa multithreading in C (terrible idea, isn't it?)


  • Subject: Cocoa multithreading in C (terrible idea, isn't it?)
  • From: Christos Papachristou <email@hidden>
  • Date: Wed, 21 Dec 2005 01:07:10 +0200

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:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Cocoa multithreading in C (terrible idea, isn't it?)
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: Setting pointer to nil
  • Next by Date: Re: Setting pointer to nil
  • Previous by thread: Re: Setting pointer to nil
  • Next by thread: Re: Cocoa multithreading in C (terrible idea, isn't it?)
  • Index(es):
    • Date
    • Thread