Minor changes to threading

- Renamed `cpp11_thread.cpp` to `thread.cpp`
- Removed features that are only supported by Win32 threads (`thread_wait` with timeout and mutex with spinlock)
- Fixed formatting in `thread.cpp`
This commit is contained in:
David Hrdlička
2021-12-17 19:59:25 +01:00
parent 149c67335a
commit 7381ab6928
16 changed files with 29 additions and 58 deletions

View File

@@ -374,7 +374,7 @@ MUNTOBJ := midi_mt32.o \
endif
ifeq ($(CPPTHREADS), y)
THREADOBJ := cpp11_thread.o
THREADOBJ := thread.o
else
THREADOBJ := win_thread.o
endif

View File

@@ -947,7 +947,7 @@ void opengl_close(void)
SetEvent(sync_objects.closing);
thread_wait(thread, -1);
thread_wait(thread);
thread_close_mutex(resize_info.mutex);
thread_close_mutex(options.mutex);

View File

@@ -45,14 +45,11 @@ thread_create(void (*func)(void *param), void *param)
int
thread_wait(thread_t *arg, int timeout)
thread_wait(thread_t *arg)
{
if (arg == NULL) return(0);
if (timeout == -1)
timeout = INFINITE;
if (WaitForSingleObject(arg, timeout)) return(1);
if (WaitForSingleObject(arg, INFINITE)) return(1);
return(0);
}
@@ -133,17 +130,6 @@ thread_create_mutex(void)
}
mutex_t *
thread_create_mutex_with_spin_count(unsigned int spin_count)
{
mutex_t *mutex = malloc(sizeof(CRITICAL_SECTION));
InitializeCriticalSectionAndSpinCount(mutex, spin_count);
return mutex;
}
int
thread_wait_mutex(mutex_t *mutex)
{