当前位置: 首页>>代码示例>>C++>>正文


C++ mutex_t::unlock方法代码示例

本文整理汇总了C++中mutex_t::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ mutex_t::unlock方法的具体用法?C++ mutex_t::unlock怎么用?C++ mutex_t::unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mutex_t的用法示例。


在下文中一共展示了mutex_t::unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

    void load(const std::string &filename){
      //---[ Load file ]------
      std::string sBuffer = readFile(filename);
      const char *buffer  = sBuffer.c_str();

      //---[ Read file ]------
      const uint32_t *buffer32 = (const uint32_t*) buffer;
      const uint64_t *buffer64;

      const uint32_t headerCount = *(buffer32++);

      for(uint32_t i = 0; i < headerCount; ++i){
        infoID_t infoID;

        const int mode_ = *(buffer32++);

        buffer64 = (const uint64_t*) buffer32;
        const uint64_t flagsOffset = *(buffer64++);
        const uint64_t flagsBytes  = *(buffer64++);

        const uint64_t contentOffset = *(buffer64++);
        const uint64_t contentBytes  = *(buffer64++);

        const uint64_t kernelNameOffset = *(buffer64++);
        const uint64_t kernelNameBytes  = *(buffer64++);

        buffer32 = (const uint32_t*) buffer64;

        infoID.kernelName = std::string(buffer + kernelNameOffset,
                                        kernelNameBytes);

        deviceIdentifier identifier(mode_,
                                    buffer + flagsOffset, flagsBytes);

        infoID.modelID = deviceModelID(identifier);

        kernelMutex.lock();
        kernelMap[infoID.kernelName].push_back(infoID.modelID);
        kernelMutex.unlock();

        //---[ Input to header map ]----
        headerMutex.lock();
        infoHeader_t &h = headerMap[infoID];

        h.fileID = fileDatabase::getFileID(filename);
        h.mode   = mode_;

        h.flagsOffset = flagsOffset;
        h.flagsBytes  = flagsBytes;

        h.contentOffset = contentOffset;
        h.contentBytes  = contentBytes;

        h.kernelNameOffset = kernelNameOffset;
        h.kernelNameBytes  = kernelNameBytes;
        headerMutex.unlock();
        //==============================
      }
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:59,代码来源:occaLibrary.cpp

示例2: cleanup

void messages::cleanup(void)
{
    linked_pointer<message> mp;
    LinkedObject *msgnext;
    unsigned msgcount = 0;
    time_t now;

    if(!pending)
        return;

    while(msgcount < keysize) {
        msglock.lock();
        time(&now);
        mp = msgs[msgcount];
        while(mp) {
            msgnext = mp->getNext();
            if(mp->expires < now) {
                mp->delist(&msgs[msgcount]);
                mp->enlist(&freelist);
            }
            mp = msgnext;
        }
        msglock.unlock();
        ++msgcount;
    }
}
开发者ID:mehulsbhatt,项目名称:sipwitch,代码行数:26,代码来源:messages.cpp

示例3: deliver

int messages::deliver(const char *to, const char *reply, const char *from, caddr_t text, size_t len, const char *msgtype, const char *digest)
{
    message *msg;

    if(!msgtype)
        msgtype = "text/plain";

    if(len > sizeof(msg->body))
        return SIP_MESSAGE_TOO_LARGE;

    msglock.lock();
    msg = static_cast<message *>(freelist);
    if(msg)
        freelist = msg->getNext();
    msglock.unlock();
    if(!msg) {
        ++allocated;
        msg = new message();
    }
    msg->create();
    String::set(msg->reply, sizeof(msg->reply), reply);
    String::set(msg->from, sizeof(msg->from), from);
    String::set(msg->type, sizeof(msg->type), msgtype);
    memset(msg->body, 0, sizeof(msg->body));
    if(len)
        memcpy(msg->body, text, len);
    msg->msglen = len;

    if(!strchr(to, '@')) {
        String::set(msg->user, sizeof(msg->user), to);
        return deliver(msg);
    }
    return remote(to, msg, digest);
}
开发者ID:mehulsbhatt,项目名称:sipwitch,代码行数:34,代码来源:messages.cpp

示例4: update

void messages::update(const char *uid)
{
    assert(uid == NULL || *uid != 0);

    linked_pointer<message> mp;
    LinkedObject *next;
    unsigned path;
    time_t now;
    if(!uid || !pending)
        return;

    path = NamedObject::keyindex(uid, keysize);
    msglock.lock();
    time(&now);
    mp = msgs[path];
    while(mp) {
        next = mp->getNext();
        if(!stricmp(mp->user, uid)) {
            --pending;
            mp->delist(&msgs[path]);
            if(mp->expires < now)
                mp->enlist(&freelist);
            else
                mp->enlist(&sending);
        }
        mp = next;
    }
    msglock.unlock();
}
开发者ID:mehulsbhatt,项目名称:sipwitch,代码行数:29,代码来源:messages.cpp

示例5: offload_timer_init

OffloadHostTimerData* offload_timer_init(const char *file, int line)
{
    static bool first_time = true;
    OffloadHostTimerData* timer_data = NULL;

    timer_data_mutex.lock();
    {
        if (timer_enabled ||
            (offload_report_level && offload_report_enabled)) {
            timer_data = (OffloadHostTimerData*)
                OFFLOAD_MALLOC(sizeof(OffloadHostTimerData), 0);
            memset(timer_data, 0, sizeof(OffloadHostTimerData));

            timer_data->offload_number = OFFLOAD_DEBUG_INCR_OFLD_NUM() - 1;

            if (timer_data_head == 0) {
                timer_data_head = timer_data;
                timer_data_tail = timer_data;
            }
            else {
                timer_data_tail->next = timer_data;
                timer_data_tail = timer_data;
            }

            timer_data->file = file;
            timer_data->line = line;
        }
    }
    timer_data_mutex.unlock();
    return timer_data;
}
开发者ID:SuperLu,项目名称:gcc,代码行数:31,代码来源:offload_timer_host.cpp

示例6: loadKernel

    kernel loadKernel(occa::device_v *dHandle,
                      const std::string &kernelName){
      infoID_t infoID;

      infoID.modelID    = dHandle->modelID();
      infoID.kernelName = kernelName;

      headerMutex.lock();
      const infoHeader_t &h = headerMap[infoID];
      headerMutex.unlock();

      const std::string hFilename = fileDatabase::getFilename(h.fileID);
      FILE *inFD = fopen(hFilename.c_str(), "rb");

      char *buffer = new char[h.contentBytes + 1];
      buffer[h.contentBytes] = '\0';

      fseek(inFD, h.contentOffset, SEEK_SET);

      ignoreResult( fread(buffer, sizeof(char), h.contentBytes, inFD) );

      fclose(inFD);

      kernel k = kernel(dHandle->loadKernelFromLibrary(buffer, kernelName));

      delete [] buffer;
      fclose(inFD);

      return k;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:30,代码来源:occaLibrary.cpp

示例7: genDeviceID

    int genDeviceID(){
      deviceIDMutex.lock();
      const int id = (currentDeviceID++);
      deviceIDMutex.unlock();

      return id;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:7,代码来源:occaLibrary.cpp

示例8: addToScratchPad

    size_t addToScratchPad(const std::string &s){
      scratchMutex.lock();

      size_t offset = scratchPad.size();
      scratchPad += s;

      scratchMutex.unlock();

      return offset;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:10,代码来源:occaLibrary.cpp

示例9: getFilename

    std::string getFilename(const int id){
      OCCA_CHECK((0 <= id) && (id < filesInDatabase),
                 "File with ID [" << id << "] was not found");

      mutex.lock();

      std::string filename = itsMap[id];

      mutex.unlock();

      return filename;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:12,代码来源:occaLibrary.cpp

示例10: deviceModelID

    int deviceModelID(const occa::deviceIdentifier &id){
      deviceModelMutex.lock();

      deviceModelMapIterator it = deviceModelMap.find(id);

      int dID;

      if(it != deviceModelMap.end())
        dID = it->second;
      else{
        dID = deviceModelMap.size();
        deviceModelMap[id] = dID;
      }

      deviceModelMutex.unlock();

      return dID;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:18,代码来源:occaLibrary.cpp

示例11: loadKernelDatabase

    occa::kernelDatabase loadKernelDatabase(const std::string &kernelName){
      kernelDatabase kdb(kernelName);

      kernelMutex.lock();

      kernelMapIterator it = kernelMap.find(kernelName);

      if(it != kernelMap.end()){
        std::vector<int> &ids = it->second;

        const int idCount = ids.size();

        for(int i = 0; i < idCount; ++i)
          kdb.modelKernelIsAvailable(ids[i]);
      }

      kernelMutex.unlock();

      return kdb;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:20,代码来源:occaLibrary.cpp

示例12: getFileID

    int getFileID(const std::string &filename){
      int id;

      mutex.lock();

      stiMapIterator it = stiMap.find(filename);

      if(it == stiMap.end()){
        id = (filesInDatabase++);

        stiMap[filename] = id;
        itsMap[id]       = filename;
      }
      else
        id = (it->second);

      mutex.unlock();

      return id;
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:20,代码来源:occaLibrary.cpp

示例13: ClearInterruptFlag

void ClearInterruptFlag(uint32 flag)
{
	intflags_mutex.lock();
	InterruptFlags &= ~flag;
	intflags_mutex.unlock();
}
开发者ID:tycho,项目名称:sheepshaver,代码行数:6,代码来源:main_windows.cpp

示例14: SetInterruptFlag

void SetInterruptFlag(uint32 flag)
{
	intflags_mutex.lock();
	InterruptFlags |= flag;
	intflags_mutex.unlock();
}
开发者ID:tycho,项目名称:sheepshaver,代码行数:6,代码来源:main_windows.cpp

示例15: save

    void save(const std::string &filename){
      headerMutex.lock();

      FILE *outFD = fopen(filename.c_str(), "wb");

      uint32_t headerCount = headerMap.size();

      if(headerCount == 0){
        headerMutex.unlock();
        return;
      }

      fwrite(&headerCount, sizeof(uint32_t), 1, outFD);

      cHeaderMapIterator it = headerMap.begin();

      const uint64_t headerOffset = headerCount * ((  sizeof(uint32_t)) +
                                                   (6*sizeof(uint64_t)));

      uint64_t contentOffsets = sizeof(headerCount) + headerOffset;

      for(uint32_t i = 0; i < headerCount; ++i){
        const infoHeader_t &h = it->second;

        fwrite(&(h.mode), sizeof(uint32_t), 1, outFD);

        fwrite(&(contentOffsets), sizeof(uint64_t), 1, outFD);
        fwrite(&(h.flagsBytes)  , sizeof(uint64_t), 1, outFD);
        contentOffsets += h.flagsBytes;

        fwrite(&(contentOffsets), sizeof(uint64_t), 1, outFD);
        fwrite(&(h.contentBytes), sizeof(uint64_t), 1, outFD);
        contentOffsets += h.contentBytes;

        fwrite(&(contentOffsets)   , sizeof(uint64_t), 1, outFD);
        fwrite(&(h.kernelNameBytes), sizeof(uint64_t), 1, outFD);
        contentOffsets += h.kernelNameBytes;

        ++it;
      }

      it = headerMap.begin();

      for(uint32_t i = 0; i < headerCount; ++i){
        const infoHeader_t &h = it->second;
        ++it;

        char *buffer = new char[std::max(h.flagsBytes,
                                         std::max(h.contentBytes,
                                                  h.kernelNameBytes))];

        if(0 <= h.fileID){
          const std::string hFilename = fileDatabase::getFilename(h.fileID);
          FILE *inFD = fopen(hFilename.c_str(), "rb");

          fseek(inFD, h.flagsOffset, SEEK_SET);
          ignoreResult( fread(buffer , sizeof(char), h.flagsBytes, inFD) );
          fwrite(buffer, sizeof(char), h.flagsBytes, outFD);

          ignoreResult( fread(buffer , sizeof(char), h.contentBytes, inFD) );
          fwrite(buffer, sizeof(char), h.contentBytes, outFD);

          ignoreResult( fread(buffer , sizeof(char), h.kernelNameBytes, inFD) );
          fwrite(buffer, sizeof(char), h.kernelNameBytes, outFD);

          fclose(inFD);

          delete [] buffer;
        }
        else{
          const char *c  = scratchPad.c_str();
          const char *c1 = c + h.flagsOffset;
          const char *c2 = c + h.contentOffset;
          const char *c3 = c + h.kernelNameOffset;

          fwrite(c1, sizeof(char), h.flagsBytes     , outFD);
          fwrite(c2, sizeof(char), h.contentBytes   , outFD);
          fwrite(c3, sizeof(char), h.kernelNameBytes, outFD);
        }
      }

      fclose(outFD);

      headerMutex.unlock();
    }
开发者ID:Nasrollah,项目名称:bfam,代码行数:85,代码来源:occaLibrary.cpp


注:本文中的mutex_t::unlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。