Delete Semaphore copy and move methods (#2613)

This matches the macOS implementation.
This commit is contained in:
Andrew Gaul 2024-12-01 10:28:50 +09:00 committed by GitHub
parent 990d2e0074
commit d13396127c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,6 +79,11 @@ class Semaphore
public:
explicit Semaphore(int value) { sem_init(&mutex, 0, value); }
~Semaphore() { sem_destroy(&mutex); }
Semaphore(const Semaphore&) = delete;
Semaphore(Semaphore&&) = delete;
Semaphore& operator=(const Semaphore&) = delete;
Semaphore& operator=(Semaphore&&) = delete;
void acquire()
{
int r;
@ -86,6 +91,7 @@ class Semaphore
r = sem_wait(&mutex);
} while (r == -1 && errno == EINTR);
}
bool try_acquire()
{
int result;
@ -95,6 +101,7 @@ class Semaphore
return (0 == result);
}
void release() { sem_post(&mutex); }
private: