本文整理汇总了C++中NdbMutex_Unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ NdbMutex_Unlock函数的具体用法?C++ NdbMutex_Unlock怎么用?C++ NdbMutex_Unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NdbMutex_Unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NdbCondition_Wait
int
NdbCondition_Wait(struct NdbCondition* p_cond,
NdbMutex* p_mutex)
{
int result;
int bLastWaiter;
if(!p_cond || !p_mutex)
return 1;
NdbMutex_Lock(p_cond->pNdbMutexWaitersLock);
p_cond->nWaiters++;
NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock);
if(NdbMutex_Unlock(p_mutex))
return -1;
result = WaitForSingleObject (p_cond->hSemaphore, INFINITE);
NdbMutex_Lock(p_cond->pNdbMutexWaitersLock);
p_cond->nWaiters--;
bLastWaiter = (p_cond->bWasBroadcast && p_cond->nWaiters==0);
NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock);
if(result==WAIT_OBJECT_0 && bLastWaiter)
SetEvent(p_cond->hEventWaitersDone);
NdbMutex_Lock(p_mutex);
return result;
}
示例2: NdbMutex_Lock
void
NdbPool::return_ndb_object(Ndb* returned_ndb, Uint32 id)
{
NdbMutex_Lock(pool_mutex);
assert(id <= m_max_ndb_objects);
assert(id != 0);
assert(returned_ndb == m_pool_reference[id].ndb_reference);
bool wait_cond = m_waiting;
if (wait_cond) {
NdbCondition* pool_cond;
if (m_signal_count > 0) {
pool_cond = output_pool_cond;
m_signal_count--;
} else {
pool_cond = input_pool_cond;
}
add_wait_list(id);
NdbMutex_Unlock(pool_mutex);
NdbCondition_Signal(pool_cond);
} else {
add_free_list(id);
add_db_hash(id);
NdbMutex_Unlock(pool_mutex);
}
}
示例3: NdbMutex_Lock
void
MgmApiSession::get_session(SocketServer::Session *_s, void *data)
{
struct get_session_param *p= (struct get_session_param*)data;
MgmApiSession *s= (MgmApiSession *)_s;
if(s!=p->l)
NdbMutex_Lock(s->m_mutex);
if(p->id != s->m_session_id)
{
if(s!=p->l)
NdbMutex_Unlock(s->m_mutex);
return;
}
p->found= true;
p->l->m_output->println("id: %llu",s->m_session_id);
p->l->m_output->println("m_stopSelf: %d",s->m_stopSelf);
p->l->m_output->println("m_stop: %d",s->m_stop);
p->l->m_output->println("nodeid: %d",s->m_allocated_resources->get_nodeid());
if(s->m_ctx)
{
int l= strlen(s->m_ctx->m_tokenBuffer);
p->l->m_output->println("parser_buffer_len: %u",l);
p->l->m_output->println("parser_status: %d",s->m_ctx->m_status);
}
if(s!=p->l)
NdbMutex_Unlock(s->m_mutex);
}
示例4: NdbCondition_WaitTimeout
int
NdbCondition_WaitTimeout(struct NdbCondition* p_cond,
NdbMutex* p_mutex,
int msecs)
{
int result;
int bLastWaiter;
if (!p_cond || !p_mutex)
return 1;
NdbMutex_Lock(p_cond->pNdbMutexWaitersLock);
p_cond->nWaiters++;
NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock);
if(msecs<0)
msecs = 0;
if(NdbMutex_Unlock(p_mutex))
return -1;
result = WaitForSingleObject(p_cond->hSemaphore, msecs);
NdbMutex_Lock(p_cond->pNdbMutexWaitersLock);
p_cond->nWaiters--;
bLastWaiter = (p_cond->bWasBroadcast && p_cond->nWaiters==0);
NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock);
if(result!=WAIT_OBJECT_0)
result = -1;
if(bLastWaiter)
SetEvent(p_cond->hEventWaitersDone);
NdbMutex_Lock(p_mutex);
return result;
}
示例5: NdbMutex_Lock
int NdbObjectIdMap::expand(Uint32 incSize)
{
NdbMutex_Lock(m_mutex);
Uint32 newSize = m_size + incSize;
MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
if (likely(tmp != 0))
{
m_map = tmp;
for(Uint32 i = m_size; i < newSize; i++){
m_map[i].m_next = i + 1;
}
m_firstFree = m_size;
m_map[newSize-1].m_next = InvalidId;
m_size = newSize;
}
else
{
NdbMutex_Unlock(m_mutex);
g_eventLogger.error("NdbObjectIdMap::expand: realloc(%u*%u) failed",
newSize, sizeof(MapEntry));
return -1;
}
NdbMutex_Unlock(m_mutex);
return 0;
}
示例6: NdbMutex_Lock
void MultiNdbWakeupHandler::registerNdb(Ndb *obj, Uint32 pos)
{
NdbMutex_Lock(obj->theImpl->m_mutex);
obj->theImpl->wakeHandler = this;
/* It may already have some completed transactions */
if (obj->theNoOfCompletedTransactions)
{
NdbMutex_Lock(localWakeupMutexPtr);
numNdbsWithCompletedTrans++;
NdbMutex_Unlock(localWakeupMutexPtr);
}
NdbMutex_Unlock(obj->theImpl->m_mutex);
}
示例7: NdbMutex_Lock
void NDBT_Context::wait_timeout(int msec){
NdbMutex_Lock(propertyMutexPtr);
NdbCondition_WaitTimeout(propertyCondPtr,
propertyMutexPtr,
msec);
NdbMutex_Unlock(propertyMutexPtr);
}
示例8: threadStart
void
ArbitMgr::threadMain()
{
ArbitSignal aSignal;
aSignal = theInputBuffer;
threadStart(aSignal);
bool stop = false;
while (! stop) {
NdbMutex_Lock(theInputMutex);
while (! theInputFull) {
NdbCondition_WaitTimeout(theInputCond, theInputMutex, theInputTimeout);
threadTimeout();
}
aSignal = theInputBuffer;
theInputFull = false;
NdbCondition_Signal(theInputCond);
NdbMutex_Unlock(theInputMutex);
switch (aSignal.gsn) {
case GSN_ARBIT_CHOOSEREQ:
threadChoose(aSignal);
break;
case GSN_ARBIT_STOPORD:
stop = true;
break;
}
}
threadStop(aSignal);
}
示例9: defined
void
AsyncFile::doStart()
{
// Stacksize for filesystem threads
#if !defined(DBUG_OFF) && defined (__hpux)
// Empirical evidence indicates at least 32k
const NDB_THREAD_STACKSIZE stackSize = 32768;
#else
// Otherwise an 8k stack should be enough
const NDB_THREAD_STACKSIZE stackSize = 8192;
#endif
char buf[16];
numAsyncFiles++;
BaseString::snprintf(buf, sizeof(buf), "AsyncFile%d", numAsyncFiles);
theStartMutexPtr = NdbMutex_Create();
theStartConditionPtr = NdbCondition_Create();
NdbMutex_Lock(theStartMutexPtr);
theStartFlag = false;
theThreadPtr = NdbThread_Create(runAsyncFile,
(void**)this,
stackSize,
(char*)&buf,
NDB_THREAD_PRIO_MEAN);
if (theThreadPtr == 0)
ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread");
NdbCondition_Wait(theStartConditionPtr,
theStartMutexPtr);
NdbMutex_Unlock(theStartMutexPtr);
NdbMutex_Destroy(theStartMutexPtr);
NdbCondition_Destroy(theStartConditionPtr);
}
示例10: sizeof
void
AsyncFile::doStart(Uint32 nodeId,
const char * filesystemPath,
const char * backup_path) {
theFileName.init(nodeId, filesystemPath, backup_path);
// Stacksize for filesystem threads
// An 8k stack should be enough
const NDB_THREAD_STACKSIZE stackSize = 8192;
char buf[16];
numAsyncFiles++;
BaseString::snprintf(buf, sizeof(buf), "AsyncFile%d", numAsyncFiles);
theStartMutexPtr = NdbMutex_Create();
theStartConditionPtr = NdbCondition_Create();
NdbMutex_Lock(theStartMutexPtr);
theStartFlag = false;
theThreadPtr = NdbThread_Create(runAsyncFile,
(void**)this,
stackSize,
(char*)&buf,
NDB_THREAD_PRIO_MEAN);
NdbCondition_Wait(theStartConditionPtr,
theStartMutexPtr);
NdbMutex_Unlock(theStartMutexPtr);
NdbMutex_Destroy(theStartMutexPtr);
NdbCondition_Destroy(theStartConditionPtr);
}
示例11: NdbMutex_Lock
bool
WatchDog::registerWatchedThread(Uint32 *counter, Uint32 threadId)
{
bool ret;
NdbMutex_Lock(m_mutex);
if (m_watchedCount >= MAX_WATCHED_THREADS)
{
ret = false;
}
else
{
m_watchedList[m_watchedCount].m_watchCounter = counter;
m_watchedList[m_watchedCount].m_threadId = threadId;
m_watchedList[m_watchedCount].m_startTicks = NdbTick_getCurrentTicks();
m_watchedList[m_watchedCount].m_slowWarnDelay = theInterval;
m_watchedList[m_watchedCount].m_lastCounterValue = 0;
++m_watchedCount;
ret = true;
}
NdbMutex_Unlock(m_mutex);
return ret;
}
示例12: NdbCondition_Broadcast
int NdbCondition_Broadcast(struct NdbCondition* p_cond)
{
int bHaveWaiters;
int result = 0;
if(!p_cond)
return 1;
NdbMutex_Lock(p_cond->pNdbMutexWaitersLock);
bHaveWaiters = 0;
if(p_cond->nWaiters > 0)
{
p_cond->bWasBroadcast = !0;
bHaveWaiters = 1;
}
NdbMutex_Unlock(p_cond->pNdbMutexWaitersLock);
if(bHaveWaiters)
{
if(!ReleaseSemaphore(p_cond->hSemaphore, p_cond->nWaiters, 0))
result = -1;
else if(WaitForSingleObject (p_cond->hEventWaitersDone, INFINITE) != WAIT_OBJECT_0)
result = -1;
p_cond->bWasBroadcast = 0;
}
return result;
}
示例13: DBUG_ENTER
void
ClusterMgr::doStop( ){
DBUG_ENTER("ClusterMgr::doStop");
NdbMutex_Lock(clusterMgrThreadMutex);
if(theStop){
NdbMutex_Unlock(clusterMgrThreadMutex);
DBUG_VOID_RETURN;
}
void *status;
theStop = 1;
if (theClusterMgrThread) {
NdbThread_WaitFor(theClusterMgrThread, &status);
NdbThread_Destroy(&theClusterMgrThread);
}
NdbMutex_Unlock(clusterMgrThreadMutex);
DBUG_VOID_RETURN;
}
示例14: assert
inline
void
trp_client::unlock()
{
assert(m_poll.m_locked == true);
m_poll.m_locked = false;
NdbMutex_Unlock(m_facade->theMutexPtr);
}
示例15: assert
inline
void
trp_client::unlock()
{
assert(m_send_nodes_mask.isclear()); // Nothing unsent when unlocking...
assert(m_poll.m_locked == true);
m_poll.m_locked = false;
NdbMutex_Unlock(m_mutex);
}