mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
use volatile variables
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32482 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
56c7a5fd3a
commit
695c2d279c
1 changed files with 8 additions and 5 deletions
|
@ -11,10 +11,13 @@
|
|||
# define mySleep(X) sleep(X)
|
||||
#endif
|
||||
|
||||
static unsigned initialize_entered = 0;
|
||||
static unsigned initialize_exited = 0;
|
||||
static unsigned class_entered = 0;
|
||||
static BOOL may_proceed = NO;
|
||||
/* Use volatile variables so compiler optimisation won't prevent one thread
|
||||
* from seeing changes made by another.
|
||||
*/
|
||||
static volatile unsigned initialize_entered = 0;
|
||||
static volatile unsigned initialize_exited = 0;
|
||||
static volatile unsigned class_entered = 0;
|
||||
static volatile BOOL may_proceed = NO;
|
||||
|
||||
@interface MyClass : NSObject
|
||||
@end
|
||||
|
@ -25,7 +28,7 @@ static BOOL may_proceed = NO;
|
|||
{
|
||||
initialize_entered++;
|
||||
while (NO == may_proceed)
|
||||
mySleep(1);
|
||||
;
|
||||
initialize_exited++;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue