307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
#endif
}
static OF_INLINE BOOL
of_spinlock_lock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
# ifdef OF_HAVE_SCHED_YIELD
int i;
for (i = 0; i < OF_SPINCOUNT; i++)
if (of_spinlock_trylock(s))
return YES;
while (!of_spinlock_trylock(s))
sched_yield();
# else
while (!of_spinlock_trylock(s));
# endif
return YES;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_lock(s) ? NO : YES);
|
|
>
>
>
>
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
|
#endif
}
static OF_INLINE BOOL
of_spinlock_lock(of_spinlock_t *s)
{
#if defined(OF_ATOMIC_OPS)
# if defined(OF_HAVE_SCHED_YIELD) || defined(_WIN32)
int i;
for (i = 0; i < OF_SPINCOUNT; i++)
if (of_spinlock_trylock(s))
return YES;
while (!of_spinlock_trylock(s))
# ifndef _WIN32
sched_yield();
# else
Sleep(0);
# endif
# else
while (!of_spinlock_trylock(s));
# endif
return YES;
#elif defined(OF_HAVE_PTHREAD_SPINLOCKS)
return (pthread_spin_lock(s) ? NO : YES);
|