2017-12-25 15:48:41 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class ProcessSemaphore
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// action: 0 MustGet 1 MustCreateNew
|
2017-12-27 11:45:21 +08:00
|
|
|
ProcessSemaphore(int key,int action=0,int default_value=1);
|
|
|
|
bool isReady() const;
|
|
|
|
int p(); /// wait
|
|
|
|
int v(); /// notify
|
|
|
|
int wait(); /// p
|
|
|
|
int notify(); /// v
|
|
|
|
~ProcessSemaphore();
|
2017-12-25 15:48:41 +08:00
|
|
|
private:
|
|
|
|
class impl;
|
|
|
|
impl* _p;
|
|
|
|
};
|