interface/semaphore
This commit is contained in:
parent
ec0dee89a1
commit
62d3c66760
@ -102,6 +102,7 @@ set(BUILDAT_CORE_SRCS
|
||||
src/impl/noise.cpp
|
||||
src/impl/voxel_volume.cpp
|
||||
src/impl/compress.cpp
|
||||
src/impl/worker_thread.cpp
|
||||
)
|
||||
if(WIN32)
|
||||
set(BUILDAT_CORE_SRCS ${BUILDAT_CORE_SRCS} src/impl/windows/file_watch.cpp)
|
||||
|
32
src/interface/semaphore.h
Normal file
32
src/interface/semaphore.h
Normal file
@ -0,0 +1,32 @@
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
|
||||
#pragma once
|
||||
#include "core/types.h"
|
||||
#ifdef _WIN32
|
||||
#include "ports/windows_compat.h"
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#endif
|
||||
|
||||
namespace interface
|
||||
{
|
||||
struct Semaphore
|
||||
{
|
||||
sem_t sem;
|
||||
|
||||
Semaphore(unsigned int value = 0){
|
||||
sem_init(&sem, 0, value);
|
||||
}
|
||||
~Semaphore(){
|
||||
sem_destroy(&sem);
|
||||
}
|
||||
void wait(){
|
||||
sem_wait(&sem);
|
||||
}
|
||||
void post(){
|
||||
sem_post(&sem);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// vim: set noet ts=4 sw=4:
|
Loading…
x
Reference in New Issue
Block a user