cwmutex.h : Added signalCondVar().
This commit is contained in:
parent
ab37affd10
commit
2fbd8b690f
20
cwMutex.cpp
20
cwMutex.cpp
@ -27,10 +27,10 @@ namespace cw
|
|||||||
int sysRC;
|
int sysRC;
|
||||||
|
|
||||||
if((sysRC = pthread_cond_destroy(&p->cvar)) != 0)
|
if((sysRC = pthread_cond_destroy(&p->cvar)) != 0)
|
||||||
cwLogSysError(kObjFreeFailRC,sysRC,"Thread condition var. destroy failed.");
|
rc = cwLogSysError(kObjFreeFailRC,sysRC,"Thread condition var. destroy failed.");
|
||||||
else
|
else
|
||||||
if((sysRC = pthread_mutex_destroy(&p->mutex)) != 0)
|
if((sysRC = pthread_mutex_destroy(&p->mutex)) != 0)
|
||||||
cwLogSysError(kObjFreeFailRC,sysRC,"Thread mutex destroy failed.");
|
rc = cwLogSysError(kObjFreeFailRC,sysRC,"Thread mutex destroy failed.");
|
||||||
else
|
else
|
||||||
mem::release(p);
|
mem::release(p);
|
||||||
|
|
||||||
@ -54,6 +54,8 @@ cw::rc_t cw::mutex::create( handle_t& h )
|
|||||||
if((sysRC = pthread_cond_init(&p->cvar,NULL)) != 0 )
|
if((sysRC = pthread_cond_init(&p->cvar,NULL)) != 0 )
|
||||||
cwLogSysError(kObjAllocFailRC,sysRC,"Thread Condition var. create failed.");
|
cwLogSysError(kObjAllocFailRC,sysRC,"Thread Condition var. create failed.");
|
||||||
|
|
||||||
|
h.set(p);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,3 +157,17 @@ cw::rc_t cw::mutex::waitOnCondVar( handle_t h, bool lockThenWaitFl, unsigned tim
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw::rc_t cw::mutex::signalCondVar( handle_t h)
|
||||||
|
{
|
||||||
|
|
||||||
|
rc_t rc = kOkRC;
|
||||||
|
mutex_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
|
int sysRC;
|
||||||
|
if((sysRC = pthread_cond_signal(&p->cvar)) != 0 )
|
||||||
|
rc = cwLogSysError(kOpFailRC,sysRC,"Thread cond var. signaling failed.");
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,13 @@ namespace cw
|
|||||||
rc_t lock( handle_t h );
|
rc_t lock( handle_t h );
|
||||||
rc_t unlock( handle_t h );
|
rc_t unlock( handle_t h );
|
||||||
|
|
||||||
|
// Set 'lockThenWaitFl' if the function should lock the mutex prior to waiting.
|
||||||
|
// If 'lockThenWaitFl' is false then the function assumes the mutex is already locked
|
||||||
|
// and directly waits. If 'lockThenWaitFl' is set and the mutex is not already locked
|
||||||
|
// then the result is undefined.
|
||||||
rc_t waitOnCondVar( handle_t h, bool lockThenWaitFl, unsigned timeOutMs );
|
rc_t waitOnCondVar( handle_t h, bool lockThenWaitFl, unsigned timeOutMs );
|
||||||
|
|
||||||
|
rc_t signalCondVar( handle_t h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user