git-svn-id: svn://db.shs.com.ru/pip@319 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -48,12 +48,6 @@ PIMutex::~PIMutex() {
|
||||
}
|
||||
|
||||
|
||||
PIMutex & PIMutex::operator =(const PIMutex & other) {
|
||||
init();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void PIMutex::lock() {
|
||||
#ifdef WINDOWS
|
||||
WaitForSingleObject(mutex, INFINITE);
|
||||
|
||||
@@ -34,13 +34,12 @@ public:
|
||||
|
||||
//! Constructs unlocked mutex
|
||||
explicit PIMutex();
|
||||
|
||||
explicit PIMutex(const PIMutex & );
|
||||
|
||||
~PIMutex();
|
||||
|
||||
|
||||
PIMutex & operator =(const PIMutex & other);
|
||||
|
||||
|
||||
//! \brief Lock mutex
|
||||
//! \details If mutex is unlocked it set to locked state and returns immediate.
|
||||
//! If mutex is already locked function blocks until mutex will be unlocked
|
||||
@@ -59,6 +58,8 @@ public:
|
||||
bool isLocked() const;
|
||||
|
||||
private:
|
||||
void operator =(const PIMutex & );
|
||||
|
||||
void init();
|
||||
void destroy();
|
||||
|
||||
|
||||
@@ -105,6 +105,64 @@ bool _PITimerBase::stop() {
|
||||
|
||||
|
||||
|
||||
class _PITimerImp_Thread: public _PITimerBase {
|
||||
public:
|
||||
_PITimerImp_Thread();
|
||||
virtual ~_PITimerImp_Thread();
|
||||
protected:
|
||||
void prepareStart(double interval_ms);
|
||||
bool threadFunc(); // returns true if repeat is needed
|
||||
int wait_dt, wait_dd, wait_tick;
|
||||
private:
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
static void threadFuncS(void * d) {((_PITimerImp_Thread*)d)->threadFunc();}
|
||||
void adjustTimes();
|
||||
|
||||
PIThread thread_;
|
||||
PISystemTime st_time, st_inc, st_wait, st_odt;
|
||||
};
|
||||
|
||||
|
||||
#ifdef PIP_TIMER_RT
|
||||
struct _PITimerImp_RT_Private_;
|
||||
class _PITimerImp_RT: public _PITimerBase {
|
||||
public:
|
||||
_PITimerImp_RT();
|
||||
virtual ~_PITimerImp_RT();
|
||||
protected:
|
||||
private:
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
|
||||
int ti;
|
||||
_PITimerImp_RT_Private_ * priv;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class _PITimerImp_Pool: public _PITimerImp_Thread {
|
||||
public:
|
||||
_PITimerImp_Pool();
|
||||
virtual ~_PITimerImp_Pool() {stop();}
|
||||
private:
|
||||
class Pool: public PIThread {
|
||||
public:
|
||||
Pool();
|
||||
~Pool();
|
||||
static Pool * instance();
|
||||
void add(_PITimerImp_Pool * t);
|
||||
void remove(_PITimerImp_Pool * t);
|
||||
void run();
|
||||
PIVector<_PITimerImp_Pool * > timers, to_remove;
|
||||
};
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
_PITimerImp_Thread::_PITimerImp_Thread() {
|
||||
thread_.setName("__S__PITimerImp_Thread::thread");
|
||||
wait_dt = 100;
|
||||
|
||||
@@ -71,63 +71,6 @@ protected:
|
||||
|
||||
|
||||
|
||||
class _PITimerImp_Thread: public _PITimerBase {
|
||||
public:
|
||||
_PITimerImp_Thread();
|
||||
virtual ~_PITimerImp_Thread();
|
||||
protected:
|
||||
void prepareStart(double interval_ms);
|
||||
bool threadFunc(); // returns true if repeat is needed
|
||||
int wait_dt, wait_dd, wait_tick;
|
||||
private:
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
static void threadFuncS(void * d) {((_PITimerImp_Thread*)d)->threadFunc();}
|
||||
void adjustTimes();
|
||||
|
||||
PIThread thread_;
|
||||
PISystemTime st_time, st_inc, st_wait, st_odt;
|
||||
};
|
||||
|
||||
|
||||
#ifdef PIP_TIMER_RT
|
||||
struct _PITimerImp_RT_Private_;
|
||||
class _PITimerImp_RT: public _PITimerBase {
|
||||
public:
|
||||
_PITimerImp_RT();
|
||||
virtual ~_PITimerImp_RT();
|
||||
protected:
|
||||
private:
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
|
||||
int ti;
|
||||
_PITimerImp_RT_Private_ * priv;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class _PITimerImp_Pool: public _PITimerImp_Thread {
|
||||
public:
|
||||
_PITimerImp_Pool();
|
||||
virtual ~_PITimerImp_Pool() {stop();}
|
||||
private:
|
||||
class Pool: public PIThread {
|
||||
public:
|
||||
Pool();
|
||||
~Pool();
|
||||
static Pool * instance();
|
||||
void add(_PITimerImp_Pool * t);
|
||||
void remove(_PITimerImp_Pool * t);
|
||||
void run();
|
||||
PIVector<_PITimerImp_Pool * > timers, to_remove;
|
||||
};
|
||||
virtual bool startTimer(double interval_ms);
|
||||
virtual bool stopTimer();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class PITimer: public PIObject {
|
||||
PIOBJECT_SUBCLASS(PITimer, PIObject)
|
||||
|
||||
Reference in New Issue
Block a user