Should getWorkLoop be thread-safe?
Should getWorkLoop be thread-safe?
- Subject: Should getWorkLoop be thread-safe?
- From: Howard Gayle <email@hidden>
- Date: Thu, 03 Aug 2006 10:10:36 -0400
Apple's "I/O Kit Fundamentals" guide
http://developer.apple.com/documentation/DeviceDrivers/Conceptual/IOKitFundamentals/index.html
has an example under
Handling Events > Work Loops > Listing 7-1
of overriding getWorkLoop(). The example tries to make
getWorkLoop() thread-safe. I have some concerns about the
example code, but does getWorkLoop() really need to be
thread-safe? I couldn't find any real code that worries about
this. The code in AppleRAIDSet.cpp in AppleRAID is pretty
typical:
IOWorkLoop * AppleRAIDSet::getWorkLoop(void)
{
// Create a WorkLoop if it has not already been done.
if (arSetWorkLoop == 0) {
arSetWorkLoop = IOWorkLoop::workLoop();
}
return arSetWorkLoop;
}
Is there a race condition where two different threads could call
getWorkLoop(), resulting in the unwanted creation of two
different IOWorkLoop objects?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden