39 |
#include <time.h> |
#include <time.h> |
40 |
#endif |
#endif |
41 |
|
|
42 |
|
#include "Foundation/NSException.h" |
43 |
#include "Foundation/NSThread.h" |
#include "Foundation/NSThread.h" |
44 |
#include "Foundation/NSLock.h" |
#include "Foundation/NSLock.h" |
45 |
#include "Foundation/NSString.h" |
#include "Foundation/NSString.h" |
367 |
gnustep_base_thread_callback() |
gnustep_base_thread_callback() |
368 |
{ |
{ |
369 |
/* |
/* |
370 |
* Post a notification if this is the first new thread to be created. |
* Protect this function with locking ... to avoid any possibility |
371 |
* Won't work properly if threads are not all created by this class, |
* of multiple threads registering with the system simultaneously, |
372 |
* but it's better than nothing. |
* and so that all NSWillBecomeMultiThreadedNotifications are sent |
373 |
|
* out before any second thread can interfere with anything. |
374 |
*/ |
*/ |
375 |
if (entered_multi_threaded_state == NO) |
if (entered_multi_threaded_state == NO) |
376 |
{ |
{ |
377 |
entered_multi_threaded_state = YES; |
[gnustep_global_lock lock]; |
378 |
|
if (entered_multi_threaded_state == NO) |
|
[GSPerformHolder class]; // Force initialization |
|
|
|
|
|
if (nc == nil) |
|
379 |
{ |
{ |
380 |
nc = [NSNotificationCenter defaultCenter]; |
NS_DURING |
381 |
|
{ |
382 |
|
[GSPerformHolder class]; // Force initialization |
383 |
|
|
384 |
|
/* |
385 |
|
* Post a notification if this is the first new thread |
386 |
|
* to be created. |
387 |
|
* Won't work properly if threads are not all created |
388 |
|
* by this class, but it's better than nothing. |
389 |
|
*/ |
390 |
|
if (nc == nil) |
391 |
|
{ |
392 |
|
nc = [NSNotificationCenter defaultCenter]; |
393 |
|
} |
394 |
|
[nc postNotificationName: NSWillBecomeMultiThreadedNotification |
395 |
|
object: nil |
396 |
|
userInfo: nil]; |
397 |
|
} |
398 |
|
NS_HANDLER |
399 |
|
{ |
400 |
|
} |
401 |
|
NS_ENDHANDLER |
402 |
|
entered_multi_threaded_state = YES; |
403 |
} |
} |
404 |
[nc postNotificationName: NSWillBecomeMultiThreadedNotification |
[gnustep_global_lock unlock]; |
|
object: nil |
|
|
userInfo: nil]; |
|
405 |
} |
} |
406 |
} |
} |
407 |
|
|