本文整理汇总了C++中pthread_rwlock_unlock函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_rwlock_unlock函数的具体用法?C++ pthread_rwlock_unlock怎么用?C++ pthread_rwlock_unlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_rwlock_unlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: release_symbols_lock
static void
release_symbols_lock(YogEnv* env, YogVM* vm)
{
pthread_rwlock_unlock(&vm->sym_lock);
}
示例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;
}
示例3: fslist_unlock
void fslist_unlock(fslist_p fs_p)
{
pthread_rwlock_unlock(&fs_p->lock);
}
示例4: md_cache_lru_unlock
int md_cache_lru_unlock( struct md_syndicate_cache* cache ) {
return pthread_rwlock_unlock( &cache->cache_lru_lock );
}
示例5: Severe
RWMutexLock::~RWMutexLock() {
int err;
if ((err = pthread_rwlock_unlock(&mutex.mutex)) != 0)
Severe("Error from pthread_rwlock_unlock: %s", strerror(err));
}
示例6: md_cache_promotes_unlock
int md_cache_promotes_unlock( struct md_syndicate_cache* cache ) {
return pthread_rwlock_unlock( &cache->promotes_lock );
}
示例7: md_cache_pending_unlock
int md_cache_pending_unlock( struct md_syndicate_cache* cache ) {
return pthread_rwlock_unlock( &cache->pending_lock );
}
示例8: pthread_rwlock_unlock
int Mutex::unlock(std::string __file__, int __line__){
std::string debug = this->reporte(__file__,__line__);
return pthread_rwlock_unlock(&mutex);
}
示例9: uv_rwlock_wrunlock
void uv_rwlock_wrunlock(uv_rwlock_t* rwlock) {
if (pthread_rwlock_unlock(rwlock))
abort();
}
示例10: pthread_rwlock_rdlock
unsigned ORBIndex::getTotalNbIndexedImages()
{
pthread_rwlock_rdlock(&rwLock);
return nbWords.size();
pthread_rwlock_unlock(&rwLock);
}
示例11: pthread_rwlock_unlock
void cRwLock::Unlock(void)
{
pthread_rwlock_unlock(&rwlock);
}
示例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;
}
}
示例13: release_packages_lock
static void
release_packages_lock(YogEnv* env, YogVM* vm)
{
pthread_rwlock_unlock(&vm->pkgs_lock);
}
示例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");
}
示例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;
}