Skip to content

Commit a5d1e20

Browse files
Add missing GCFreeZone calls for semaphores and condition variables.
1 parent 9d9b920 commit a5d1e20

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/hx/Thread.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,19 @@ class hxSemaphore : public hx::Object {
533533
#endif
534534

535535
void Acquire() {
536+
hx::EnterGCFreeZone();
536537
#if HX_WINDOWS
537538
WaitForSingleObject(sem, INFINITE);
538539
#elif defined(POSIX_SEMAPHORE)
539540
sem_wait(&sem);
540541
#elif defined(APPLE_SEMAPHORE)
541542
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
542543
#endif
544+
hx::ExitGCFreeZone();
543545
}
544546

545547
bool TryAcquire(double timeout) {
548+
hx::AutoGCFreeZone blocking;
546549
#ifdef HX_WINDOWS
547550
return WaitForSingleObject(sem, (DWORD)((FLOAT)timeout * 1000.0)) == 0;
548551
#elif defined(POSIX_SEMAPHORE)
@@ -678,13 +681,15 @@ class hxCondition : public hx::Object {
678681
}
679682

680683
void Acquire() {
684+
hx::EnterGCFreeZone();
681685
#ifdef HX_WINDOWS
682686
#ifndef HXCPP_WINXP_COMPAT
683687
EnterCriticalSection(&cs);
684688
#endif
685689
#else
686690
pthread_mutex_lock(mutex);
687691
#endif
692+
hx::ExitGCFreeZone();
688693
}
689694

690695
bool TryAcquire() {
@@ -710,16 +715,19 @@ class hxCondition : public hx::Object {
710715
}
711716

712717
void Wait() {
718+
hx::EnterGCFreeZone();
713719
#ifdef HX_WINDOWS
714720
#ifndef HXCPP_WINXP_COMPAT
715721
SleepConditionVariableCS(&cond,&cs,INFINITE);
716722
#endif
717723
#else
718724
pthread_cond_wait(cond, mutex);
719725
#endif
726+
hx::ExitGCFreeZone();
720727
}
721728

722729
bool TimedWait(double timeout) {
730+
hx::AutoGCFreeZone blocking;
723731
#ifdef HX_WINDOWS
724732
#ifndef HXCPP_WINXP_COMPAT
725733
return (bool)SleepConditionVariableCS(&cond, &cs, (DWORD)((FLOAT)timeout * 1000.0));

0 commit comments

Comments
 (0)