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

C++ pthread_rwlock_unlock函数代码示例

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

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



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

示例1: release_symbols_lock

static void
release_symbols_lock(YogEnv* env, YogVM* vm)
{
    pthread_rwlock_unlock(&vm->sym_lock);
}
开发者ID:SumiTomohiko,项目名称:Yog,代码行数:5,代码来源:vm.c


示例2: psyslog

void *read_sock(void *p)
{
    if(p==NULL)
        return NULL;

    char szBuf[MAX_SIZE*5] = {0};
    SOCKDATA *pdata = (SOCKDATA*)p;

	int nbytes;
    if((nbytes=recv(pdata->sock_fd, szBuf, MAX_SIZE, 0))==-1 || nbytes==0){
		psyslog(LOG_NOTICE, "From client %d recv data is %s\n", pdata->sock_fd, nbytes?"not empty":"empty");
		free(pdata);
		return NULL;
	}

	uint8_t *podata = (uint8_t*)malloc(nbytes-1);
	if(reverse_crc_data(szBuf, nbytes, (void*)podata)!=0){
        psyslog(LOG_ERR, "The data from client crc error");
		free(pdata);
		free(podata);
		return NULL;
	}
	//use JSON
	cJSON *root = cJSON_Parse((char*)podata);
    if (root == NULL){
        psyslog(LOG_ERR, cJSON_GetErrorPtr());
        free(pdata);
		free(podata);
	    return NULL;
    }

    int needResponse = cJSON_GetObjectItem(root, "needResponse")->valueint;
    char *message = cJSON_GetObjectItem(root, "message")->valuestring;
    int msgLen = cJSON_GetObjectItem(root, "len")->valueint;

	bzero(szBuf, MAX_SIZE*5);
	strncpy(szBuf, message, msgLen);
	szBuf[msgLen] = '\n';

	pthread_rwlock_wrlock(&rwlock);
    write(pdata->write_fd, szBuf, msgLen+1);
	if(needResponse)
	{
		//need respons
		bzero(szBuf, MAX_SIZE*5);

		//nbytes=read(pdata->read_fd, szBuf, MAX_SIZE*5);
		sleep(0.1);
		strcpy(szBuf, "Hello WoW!");
		nbytes = strlen(szBuf);

		pdata->msg = szBuf;
		pdata->size = nbytes;
		write_sock(pdata);
	}
	pthread_rwlock_unlock(&rwlock);

	free(pdata);
	free(podata);
	cJSON_Delete(root);

	return NULL;
}
开发者ID:NlxF,项目名称:OpenWow,代码行数:63,代码来源:aidsock.c


示例3: fslist_unlock

void fslist_unlock(fslist_p fs_p)
{
	pthread_rwlock_unlock(&fs_p->lock);
}
开发者ID:mnv104,项目名称:capfs,代码行数:4,代码来源:fslist.c


示例4: md_cache_lru_unlock

int md_cache_lru_unlock( struct md_syndicate_cache* cache ) {
   return pthread_rwlock_unlock( &cache->cache_lru_lock );
}
开发者ID:etherparty,项目名称:syndicate,代码行数:3,代码来源:cache.cpp


示例5: Severe

RWMutexLock::~RWMutexLock() {
    int err;
    if ((err = pthread_rwlock_unlock(&mutex.mutex)) != 0)
       Severe("Error from pthread_rwlock_unlock: %s", strerror(err));
}
开发者ID:jwzhang,项目名称:pbrt-v2,代码行数:5,代码来源:parallel.cpp


示例6: md_cache_promotes_unlock

int md_cache_promotes_unlock( struct md_syndicate_cache* cache ) {
   return pthread_rwlock_unlock( &cache->promotes_lock );
}
开发者ID:etherparty,项目名称:syndicate,代码行数:3,代码来源:cache.cpp


示例7: md_cache_pending_unlock

int md_cache_pending_unlock( struct md_syndicate_cache* cache ) {
   return pthread_rwlock_unlock( &cache->pending_lock );
}
开发者ID:etherparty,项目名称:syndicate,代码行数:3,代码来源:cache.cpp


示例8: pthread_rwlock_unlock

int Mutex::unlock(std::string __file__, int __line__){
	std::string debug = this->reporte(__file__,__line__); 
	return pthread_rwlock_unlock(&mutex);
}
开发者ID:martineq,项目名称:onuolbaid,代码行数:4,代码来源:Mutex.cpp


示例9: uv_rwlock_wrunlock

void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) {
  if (pthread_rwlock_unlock(rwlock))
    abort();
}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:4,代码来源:thread.c


示例10: pthread_rwlock_rdlock

unsigned ORBIndex::getTotalNbIndexedImages()
{
    pthread_rwlock_rdlock(&rwLock);
    return nbWords.size();
    pthread_rwlock_unlock(&rwLock);
}
开发者ID:albertofernandezvillan,项目名称:pastec,代码行数:6,代码来源:orbindex.cpp


示例11: pthread_rwlock_unlock

void cRwLock::Unlock(void)
{
  pthread_rwlock_unlock(&rwlock);
}
开发者ID:suborb,项目名称:reelvdr,代码行数:4,代码来源:thread.c


示例12: BackwardIndexReaderFileAccess

/**
 * @brief Read the index and store it in memory.
 * @return true on success else false
 */
bool ORBIndex::readIndex(string backwardIndexPath)
{
    // Open the file.
    indexAccess = new BackwardIndexReaderFileAccess();
    if (!indexAccess->open(backwardIndexPath))
    {
        cout << "Could not open the backward index file." << endl
             << "Using an empty index." << endl;
        return false;
    }
    else
    {
        pthread_rwlock_wrlock(&rwLock);

        /* Read the table to know where are located the lines corresponding to each
         * visual word. */
        cout << "Reading the numbers of occurences." << endl;
        u_int64_t *wordOffSet = new u_int64_t[NB_VISUAL_WORDS];
        u_int64_t i_offset = NB_VISUAL_WORDS * sizeof(u_int64_t);
        for (unsigned i = 0; i < NB_VISUAL_WORDS; ++i)
        {
            indexAccess->read((char *)(nbOccurences + i), sizeof(u_int64_t));
            wordOffSet[i] = i_offset;
            i_offset += nbOccurences[i] * BACKWARD_INDEX_ENTRY_SIZE;
        }

        /* Count the number of words per image. */
        cout << "Counting the number of words per image." << endl;
        totalNbRecords = 0;
        while (!indexAccess->endOfIndex())
        {
            u_int32_t i_imageId;
            u_int16_t i_angle, x, y;
            indexAccess->read((char *)&i_imageId, sizeof(u_int32_t));
            indexAccess->read((char *)&i_angle, sizeof(u_int16_t));
            indexAccess->read((char *)&x, sizeof(u_int16_t));
            indexAccess->read((char *)&y, sizeof(u_int16_t));
            nbWords[i_imageId]++;
            totalNbRecords++;
        }

        indexAccess->reset();

        cout << "Loading the index in memory." << endl;

        for (unsigned i_wordId = 0; i_wordId < NB_VISUAL_WORDS; ++i_wordId)
        {
            indexAccess->moveAt(wordOffSet[i_wordId]);
            vector<Hit> &hits = indexHits[i_wordId];

            const unsigned i_nbOccurences = nbOccurences[i_wordId];
            hits.resize(i_nbOccurences);

            for (u_int64_t i = 0; i < i_nbOccurences; ++i)
            {
                u_int32_t i_imageId;
                u_int16_t i_angle, x, y;
                indexAccess->read((char *)&i_imageId, sizeof(u_int32_t));
                indexAccess->read((char *)&i_angle, sizeof(u_int16_t));
                indexAccess->read((char *)&x, sizeof(u_int16_t));
                indexAccess->read((char *)&y, sizeof(u_int16_t));
                hits[i].i_imageId = i_imageId;
                hits[i].i_angle = i_angle;
                hits[i].x = x;
                hits[i].y = y;
            }
        }

        delete[] wordOffSet;

        pthread_rwlock_unlock(&rwLock);

        return true;
    }
}
开发者ID:albertofernandezvillan,项目名称:pastec,代码行数:79,代码来源:orbindex.cpp


示例13: release_packages_lock

static void
release_packages_lock(YogEnv* env, YogVM* vm)
{
    pthread_rwlock_unlock(&vm->pkgs_lock);
}
开发者ID:SumiTomohiko,项目名称:Yog,代码行数:5,代码来源:vm.c


示例14: vlc_rwlock_unlock

/**
 * Releases a read/write lock.
 */
void vlc_rwlock_unlock (vlc_rwlock_t *lock)
{
    int val = pthread_rwlock_unlock (lock);
    VLC_THREAD_ASSERT ("releasing R/W lock");
}
开发者ID:cmassiot,项目名称:vlc-broadcast,代码行数:8,代码来源:pthread.c


示例15: thread_pool_main_loop

static void * thread_pool_main_loop( void * arg ) {
  thread_pool_type * tp = (thread_pool_type *) arg;
  {
    const int usleep_busy = 1000;  /* The sleep time when all job slots are occupied. */
    const int usleep_init = 1000;  /* The sleep time when there are free slots available - but no jobs wanting to run. */
    int internal_offset   = 0;     /* Keep track of the (index of) the last job slot fired off - minor time saving. */
    while (true) {
      if (tp->queue_size > tp->queue_index) {
        /* 
           There are jobs in the queue which would like to run - 
           let us see if we can find a slot for them.
        */
        int counter     = 0;
        bool slot_found = false;
        do {
          int slot_index = (counter + internal_offset) % tp->max_running;
          thread_pool_job_slot_type * job_slot = &tp->job_slots[ slot_index ];
          if (!job_slot->running) {
            /* OK thread[slot_index] is ready to take this job.*/
            thread_pool_arg_type * tp_arg;
            
            /* 
               The queue might be updated by the main thread - we must
               take a copy of the node we are interested in.
            */
            pthread_rwlock_rdlock( &tp->queue_lock );
            tp_arg = util_alloc_copy( &tp->queue[ tp->queue_index ] , sizeof * tp_arg );
            pthread_rwlock_unlock( &tp->queue_lock );            

            tp_arg->slot_index = slot_index;
            job_slot->running = true;
            /* 
               Here is the actual pthread_create() call creating an
               additional running thread.
            */
            pthread_create( &job_slot->thread , NULL , thread_pool_start_job , tp_arg );
            job_slot->run_count += 1;
            tp->queue_index++;
            internal_offset += (counter + 1);
            slot_found = true;
          } else
            counter++;
        } while (!slot_found && (counter < tp->max_running));
        
        if (!slot_found)
          util_usleep( usleep_busy );  /* There are no available job slots. */
      } else
        util_usleep( usleep_init );    /* There are no jobs wanting to run. */

      /*****************************************************************/
      /*
        We exit explicitly from this loop when both conditions apply:

         1. tp->join       == true              :  The calling scope has signaled that it will not submit more jobs. 
         2. tp->queue_size == tp->queue_index   :  This function has submitted all the jobs in the queue.
      */
      if ((tp->join) &&
          (tp->queue_size == tp->queue_index))
        break;
    } /* End of while() loop */
  }

  /* 
     There are no more jobs in the queue, and the main scope has
     signaled that join should start. Observe that we join only the
     jobs corresponding to explicitly running job_slots; when a job
     slot is used multiple times the first jobs run in the job_slot
     will not be explicitly joined.
  */
  {
    int i;
    for (i=0; i < tp->max_running; i++) {
      thread_pool_job_slot_type job_slot = tp->job_slots[i];
      if (job_slot.run_count > 0)
        pthread_join( job_slot.thread , NULL );
    }
  }
  /* When we are here all the jobs have completed. */
  return NULL;
}
开发者ID:JacobStoren,项目名称:ert,代码行数:80,代码来源:thread_pool_posix.c


示例16: do_test

static int
do_test (void)
{
  pthread_rwlock_t r;
  int e;

  if (pthread_rwlock_init (&r, NULL) != 0)
    {
      puts ("rwlock_init failed");
      return 1;
    }
  puts ("rwlock_init succeeded");

  if (pthread_rwlock_trywrlock (&r) != 0)
    {
      puts ("rwlock_trywrlock on unlocked rwlock failed");
      return 1;
    }
  puts ("rwlock_trywrlock on unlocked rwlock succeeded");

  e = pthread_rwlock_rdlock (&r);
  if (e == 0)
    {
      puts ("rwlock_rdlock on rwlock with writer succeeded");
      return 1;
    }
  if (e != EDEADLK)
    {
      puts ("rwlock_rdlock on rwlock with writer failed != EDEADLK");
      return 1;
    }
  puts ("rwlock_rdlock on rwlock with writer failed with EDEADLK");

  e = pthread_rwlock_wrlock (&r);
  if (e == 0)
    {
      puts ("rwlock_wrlock on rwlock with writer succeeded");
      return 1;
    }
  if (e != EDEADLK)
    {
      puts ("rwlock_wrlock on rwlock with writer failed != EDEADLK");
      return 1;
    }
  puts ("rwlock_wrlock on rwlock with writer failed with EDEADLK");

  if (pthread_rwlock_unlock (&r) != 0)
    {
      puts ("rwlock_unlock failed");
      return 1;
    }
  puts ("rwlock_unlock succeeded");

  if (pthread_rwlock_destroy (&r) != 0)
    {
      puts ("rwlock_destroy failed");
      return 1;
    }
  puts ("rwlock_destroy succeeded");

  return 0;
}
开发者ID:JamesLinus,项目名称:glibc-mips,代码行数:62,代码来源:tst-rwlock3.c


示例17: threadTypeB


//.........这里部分代码省略.........
        {
        case HELLO:
        {
            #ifdef DEBUG
                printHeader(ipName,portName);
                printf("receive a HELLO MSG, content is:\n");
                printMsg(ipName,portName,msg,length);
            #endif

            uint32_t length;
            int num;
            userInf uInf[MAXUSER];

            fetchFmsg(msg,&length,1);

            memcpy(screenName,&msg[5],length);
            screenName[length]=0;

            MYMSG sMsg[MSGL];
            length=createGetListMsg(sMsg);
            #ifdef DEBUG
                printHeader(ipName,portName);
                printf("get list message:\n");
                printMsg(ipName,portName,sMsg,length);
                printHeader(ipName,portName);
                printf("send to server\n");
            #endif

            write(serverSocket,sMsg,length);
            msgRecSer.receiveMsg(msg,&length);
            #ifdef DEBUG
                printHeader(ipName,portName);
                printf("receive a message from server, content is:\n");
                printMsg(ipName,portName,msg,length);
            #endif

            clientListParse(msg,uInf,&num);
            bool find=false;
            for(int i=0; i<num; i++)
            {
                if (strcmp(screenName,uInf[i].name)==0)
                {
                    find=true;
                    break;
                }
            }
            if (find)
            {
                #ifdef DEBUG
                    printHeader(ipName,portName);
                    printf("tries to send hello ok message\n");
                #endif
                pthread_rwlock_wrlock(&cConListLock);
                if (cConList.connectWith(screenName,conSocket,&msgRecCli)==TOOMANYCONNECTION)
                {
                    printf("Too many connections between clients\n");
                    delete msgRecCli;
                    close(conSocket);
                    err("Type B: makeConnection()\n",-9);
                }
                pthread_rwlock_unlock(&cConListLock);

                validClient=true;
                length=createHelloOkMsg(sMsg);
                #ifdef DEBUG
                    printHeader(ipName,portName);
                    printf("sending hello ok message\n");
                    printMsg(ipName,portName,sMsg,length);
                #endif
                write(conSocket,sMsg,length);
            }
            else
            {
                #ifdef DEBUG
                    printHeader(ipName,portName);
                    printf("unknown client\n");
                #endif
                length=createErrMsg(sMsg,0x04);
                #ifdef DEBUG
                    printHeader(ipName,portName);
                    printf("error msg is sent\n");
                    printMsg(ipName,portName,sMsg,length);
                #endif
                write(conSocket,sMsg,length);
            }
            break;
        }
        case MSG:
        {
            if (!validClient)
            {
                close(conSocket);
                err("Type B: validClient==false",NOSUCHUSER);
            }
            buf.addMsg(msg,screenName);
        }
        }
    }
    return NULL;
}
开发者ID:Alston-Tang,项目名称:CSCI4430_Ass1,代码行数:101,代码来源:client.cpp


示例18: md_cache_ongoing_writes_unlock

int md_cache_ongoing_writes_unlock( struct md_syndicate_cache* cache ) {
   return pthread_rwlock_unlock( &cache->ongoing_writes_lock );
}
开发者ID:etherparty,项目名称:syndicate,代码行数:3,代码来源:cache.cpp


示例19: cmus_rwlock_unlock

void cmus_rwlock_unlock(pthread_rwlock_t *lock)
{
	int rc = pthread_rwlock_unlock(lock);
	if (unlikely(rc))
		BUG("error unlocking mutex: %s\n", strerror(rc));
}
开发者ID:leigh123linux,项目名称:cmus,代码行数:6,代码来源:locking.c


示例20: md_cache_completed_unlock

int md_cache_completed_unlock( struct md_syndicate_cache* cache ) {
   return pthread_rwlock_unlock( &cache->completed_lock );
}
开发者ID:etherparty,项目名称:syndicate,代码行数:3,代码来源:cache.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pthread_rwlock_wrlock函数代码示例发布时间:2022-05-30
下一篇:
C++ pthread_rwlock_trywrlock函数代码示例发布时间: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