本文整理汇总了C++中NdbMutex_Lock函数的典型用法代码示例。如果您正苦于以下问题:C++ NdbMutex_Lock函数的具体用法?C++ NdbMutex_Lock怎么用?C++ NdbMutex_Lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NdbMutex_Lock函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:34,代码来源:NdbCondition.c
示例2: 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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:28,代码来源:NdbCondition.c
示例3: 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);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:13,代码来源:WakeupHandler.cpp
示例4: NdbMutex_Lock
void NDBT_Context::setProperty(const char* _name, const char* _val){
NdbMutex_Lock(propertyMutexPtr);
const bool b = props.put(_name, _val, true);
require(b == true);
NdbCondition_Broadcast(propertyCondPtr);
NdbMutex_Unlock(propertyMutexPtr);
}
开发者ID:carrotli,项目名称:ansql,代码行数:7,代码来源:NDBT_Test.cpp
示例5: 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);
}
开发者ID:leafji,项目名称:MYSQL_5.7,代码行数:28,代码来源:ClusterMgr.cpp
示例6: 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);
}
开发者ID:A-eolus,项目名称:mysql,代码行数:34,代码来源:AsyncFile.cpp
示例7: 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);
}
开发者ID:isleon,项目名称:Jaxer,代码行数:30,代码来源:AsyncFile.cpp
示例8: 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);
}
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:25,代码来源:NdbPoolImpl.cpp
示例9: 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;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:25,代码来源:WatchDog.cpp
示例10: 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);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:31,代码来源:Services.cpp
示例11: 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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:25,代码来源:NdbCondition.c
示例12: 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;
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:27,代码来源:ObjectMap.cpp
示例13: VerifyBegin
void VerifyBegin(void)
{
if(!g_pNdbMutexVerify)
{
g_pNdbMutexVerify = NdbMutex_Create();
}
NdbMutex_Lock(g_pNdbMutexVerify);
}
开发者ID:nanata1115,项目名称:mariadb,代码行数:8,代码来源:VerifyNdbApi.cpp
示例14: NdbMutex_Lock
inline
void
trp_client::lock()
{
NdbMutex_Lock(m_mutex);
assert(m_poll.m_locked == false);
m_poll.m_locked = true;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:8,代码来源:trp_client.hpp
示例15: NdbMutex_Lock
inline
void
trp_client::lock()
{
NdbMutex_Lock(m_facade->theMutexPtr);
assert(m_poll.m_locked == false);
m_poll.m_locked = true;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:8,代码来源:trp_client.hpp
示例16: TraceBegin
void TraceBegin(void)
{
if(!g_pNdbMutexTrace)
{
g_pNdbMutexTrace = NdbMutex_Create();
}
NdbMutex_Lock(g_pNdbMutexTrace);
g_nParamTrace = 0;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:9,代码来源:TraceNdbApi.cpp
示例17: DBUG_ENTER
void
MgmApiSession::runSession()
{
DBUG_ENTER("MgmApiSession::runSession");
Parser_t::Context ctx;
ctx.m_mutex= m_mutex;
m_ctx= &ctx;
bool stop= false;
while(!stop) {
NdbMutex_Lock(m_mutex);
m_input->reset_timeout();
m_output->reset_timeout();
m_parser->run(ctx, *this);
if(ctx.m_currentToken == 0)
{
NdbMutex_Unlock(m_mutex);
break;
}
switch(ctx.m_status) {
case Parser_t::UnknownCommand:
break;
default:
break;
}
stop= m_stop;
NdbMutex_Unlock(m_mutex);
};
NdbMutex_Lock(m_mutex);
m_ctx= NULL;
if(m_socket != NDB_INVALID_SOCKET)
{
NDB_CLOSE_SOCKET(m_socket);
m_socket= NDB_INVALID_SOCKET;
}
NdbMutex_Unlock(m_mutex);
DBUG_VOID_RETURN;
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:44,代码来源:Services.cpp
示例18: ndb_mutex_destoyed
void
ndb_mutex_destoyed(NdbMutex* p)
{
unsigned no = p->m_mutex_state->m_no;
/**
* In order to be able to reuse mutex_no,
* we need to clear this no from all mutexes that has it in before map...
* this is all mutexes in after map
*/
for (unsigned i = 0; i<p->m_mutex_state->m_locked_after_list.m_used; i++)
{
NdbMutex * m = get_element(&p->m_mutex_state->m_locked_after_list, i);
assert(check_bit(&p->m_mutex_state->m_locked_after_mask, m->m_mutex_state->m_no));
/**
* And we need to lock it while doing this
*/
NdbMutex_Lock(m);
assert(check_bit(&m->m_mutex_state->m_locked_before_mask, no));
clear_bit(&m->m_mutex_state->m_locked_before_mask, no);
remove_mutex_from_array(&m->m_mutex_state->m_locked_before_list, p);
NdbMutex_Unlock(m);
}
/**
* And we need to remove ourselfs from after list of mutexes in out before list
*/
for (unsigned i = 0; i<p->m_mutex_state->m_locked_before_list.m_used; i++)
{
NdbMutex * m = get_element(&p->m_mutex_state->m_locked_before_list, i);
NdbMutex_Lock(m);
assert(check_bit(&m->m_mutex_state->m_locked_after_mask, no));
clear_bit(&m->m_mutex_state->m_locked_after_mask, no);
remove_mutex_from_array(&m->m_mutex_state->m_locked_after_list, p);
NdbMutex_Unlock(m);
}
release(&p->m_mutex_state->m_locked_before_mask);
release(&p->m_mutex_state->m_locked_before_list);
release(&p->m_mutex_state->m_locked_after_mask);
release(&p->m_mutex_state->m_locked_after_list);
release_mutex_no(no);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:44,代码来源:NdbMutex_DeadlockDetector.cpp
示例19: NdbMutex_Lock
void
ClusterMgr::startThread() {
NdbMutex_Lock(clusterMgrThreadMutex);
theStop = 0;
theClusterMgrThread = NdbThread_Create(runClusterMgr_C,
(void**)this,
32768,
"ndb_clustermgr",
NDB_THREAD_PRIO_LOW);
NdbMutex_Unlock(clusterMgrThreadMutex);
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:13,代码来源:ClusterMgr.cpp
注:本文中的NdbMutex_Lock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论