• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ NdbMutex_Unlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NdbMutex_Unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ NdbMutex_Unlock函数的具体用法?C++ NdbMutex_Unlock怎么用?C++ NdbMutex_Unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NdbMutex_Unlock函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:28,代码来源:NdbCondition.c


示例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);
  }
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:25,代码来源:NdbPoolImpl.cpp


示例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);
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:31,代码来源:Services.cpp


示例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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:34,代码来源:NdbCondition.c


示例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;
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:27,代码来源:ObjectMap.cpp


示例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);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:13,代码来源:WakeupHandler.cpp


示例7: NdbMutex_Lock

void NDBT_Context::wait_timeout(int msec){
  NdbMutex_Lock(propertyMutexPtr);
  NdbCondition_WaitTimeout(propertyCondPtr,
			   propertyMutexPtr,
			   msec);
  NdbMutex_Unlock(propertyMutexPtr);
}
开发者ID:carrotli,项目名称:ansql,代码行数:7,代码来源:NDBT_Test.cpp


示例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);
}
开发者ID:leafji,项目名称:MYSQL_5.7,代码行数:28,代码来源:ClusterMgr.cpp


示例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);
}
开发者ID:A-eolus,项目名称:mysql,代码行数:34,代码来源:AsyncFile.cpp


示例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);
}
开发者ID:isleon,项目名称:Jaxer,代码行数:30,代码来源:AsyncFile.cpp


示例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;
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:25,代码来源:WatchDog.cpp


示例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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:25,代码来源:NdbCondition.c


示例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;
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:17,代码来源:ClusterMgr.cpp


示例14: assert

inline
void
trp_client::unlock()
{
  assert(m_poll.m_locked == true);
  m_poll.m_locked = false;
  NdbMutex_Unlock(m_facade->theMutexPtr);
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:8,代码来源:trp_client.hpp


示例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);
}
开发者ID:ForcerKing,项目名称:ShaoqunXu-mysql5.7,代码行数:9,代码来源:trp_client.hpp


示例16: 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


示例17: 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


示例18: NdbThreadFuncUpdate

extern "C" void* NdbThreadFuncUpdate(void* pArg)
{
    myRandom48Init((long int)NdbTick_CurrentMillisecond());
    unsigned nSucc = 0;
    unsigned nFail = 0;
    Ndb* pNdb = NULL ;
    pNdb = new Ndb("TEST_DB");
    VerifyMethodInt(pNdb, init());
    VerifyMethodInt(pNdb, waitUntilReady());

    while(NdbMutex_Trylock(g_pNdbMutex)) {
        Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
        NdbConnection* pNdbConnection = NULL ;
        VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
        CHK_TR(pNdbConnection) ; // epaulsa
        NdbOperation* pNdbOperationW = NULL ;
        VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
        VerifyMethodInt(pNdbOperationW, interpretedUpdateTuple());
        VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
        VerifyMethodInt(pNdbOperationW, incValue(c_szWarehouseCount, Uint32(1)));
        Uint32 nWarehouseSum = 0;
        for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
            NdbOperation* pNdbOperationD = NULL ;
            VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
            VerifyMethodInt(pNdbOperationD, interpretedUpdateTuple());
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
            VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
            VerifyMethodInt(pNdbOperationD, incValue(c_szDistrictCount, Uint32(1)));
            Uint32 nDistrictSum = myRandom48(100);
            nWarehouseSum += nDistrictSum;
            VerifyMethodInt(pNdbOperationD, setValue(c_szDistrictSum, nDistrictSum));
        }
        VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
        int iExec = pNdbConnection->execute(Commit);
        int iError = pNdbConnection->getNdbError().code;

        if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
            ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
        }
        if(iExec==0) {
            ++nSucc;
        } else {
            ++nFail;
        }
        VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
    }
    ndbout << "update: " << nSucc << " succeeded, " << nFail << " failed " << endl;
    NdbMutex_Unlock(g_pNdbMutex);
    delete pNdb;
    pNdb = NULL ;
    return NULL;
}
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:52,代码来源:acid.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_Unlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NdbSleep_MilliSleep函数代码示例发布时间:2022-05-30
下一篇:
C++ NdbMutex_Lock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap