• 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
Cooperative threading questions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Cooperative threading questions


  • Subject: Cooperative threading questions
  • From: Andy Wiese <email@hidden>
  • Date: Tue, 6 Mar 2007 15:03:32 -0600

Hello Cocoa Gurus,

I am new to cocoa, but trying hard to change that, so I hope my newbie questions can be forgiven.

I am trying to use some cocoa windows in a carbon application that (for inflexible and historical reasons) uses cooperative threads for all UI. This requires that all drawing and event dispatching happens in a cooperative thread. Its not pretty, and not easy, but it works ok in carbon.

Can I get a cocoa window to update in a cooperative thread? It seems that none of the display methods do anything. In a contrived example, I call the following code while handling a mousedown event. The button only gets the drawRect message when I send it directly.
// apologies, most of this is clueless thrashing...
[[window contentView] lockFocus];
[window setViewsNeedDisplay:YES];
[window display]; // nothing happens
[button setNeedsDisplay:YES];
[button lockFocus];
[button display]; // nothing happens
NSGraphicsContext* curContext = [NSGraphicsContext currentContext];
if (curContext)
{
NSFrameRect([button bounds]); // draws
[button drawRect:[button bounds]]; // draws
}
[button unlockFocus];
[[window contentView] unlockFocus];


Can modal event loops work in a cooperative thread? While dispatching an event in a cooperative thread, nextEventMatchingMask appears to always return nil. E.G. when NSButton goes into a modal mouse tracking loop, it spins endlessly getting nil from nextEventMatchingMask. I'm surprised at this, because ReceiveNextEvent can get carbon mouse events ok, and CoreFoundation says that cooperative threads share the same CFRunLoop as the main thread.

If I have to implement my own nextEventMatchingMask using carbon events, is there any utility to help me create appropriate NSEvents from Carbon events?

I will greatly appreciate any help, hints or wild conjecture. If you just want to tell me how insane the whole scheme is, flames are welcome but let's keep that off thread.

Andy Wiese

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSData and Nested Arrays
  • Next by Date: Does lockFocus (NSImage) within another context cause to drop transform info?
  • Previous by thread: Re: "You can create a window on a secondary thread."
  • Next by thread: Does lockFocus (NSImage) within another context cause to drop transform info?
  • Index(es):
    • Date
    • Thread