Skip to content

Commit

Permalink
Fixup Semaphore.hpp for macOS
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Nov 24, 2023
1 parent 73c3e7b commit cd17a31
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Semaphore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,20 @@ class Semaphore
Semaphore(const int initialValue = 0)
{
#if defined(DISTRHO_OS_MAC)
DISTRHO_SAFE_ASSERT_RETURN(semaphore_create(mach_task_self(),
&sem,
SYNC_POLICY_FIFO,
initialValue) == KERN_SUCCESS,);
task = mach_task_self();
DISTRHO_SAFE_ASSERT_RETURN(semaphore_create(task, &sem, SYNC_POLICY_FIFO, initialValue) == KERN_SUCCESS,);
#elif defined(DISTRHO_OS_WINDOWS)
handle = ::CreateSemaphoreA(nullptr, initialValue, std::max(initialValue, 1), nullptr);
DISTRHO_SAFE_ASSERT_RETURN(handle != INVALID_HANDLE_VALUE,);
#else
::sem_init(&sem, 0, initialValue);
DISTRHO_SAFE_ASSERT_RETURN(::sem_init(&sem, 0, initialValue) == 0,);
#endif
}

~Semaphore()
{
#if defined(DISTRHO_OS_MAC)
::semaphore_destroy(mach_task_self(), sem);
::semaphore_destroy(task, sem);
#elif defined(DISTRHO_OS_WINDOWS)
::CloseHandle(handle);
#else
Expand Down Expand Up @@ -95,6 +93,7 @@ class Semaphore

private:
#if defined(DISTRHO_OS_MAC)
::mach_port_t task;
::semaphore_t sem;
#elif defined(DISTRHO_OS_WINDOWS)
::HANDLE handle;
Expand Down

0 comments on commit cd17a31

Please sign in to comment.