本文整理汇总了C++中pthread_rwlock_rdlock函数的典型用法代码示例。如果您正苦于以下问题:C++ pthread_rwlock_rdlock函数的具体用法?C++ pthread_rwlock_rdlock怎么用?C++ pthread_rwlock_rdlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pthread_rwlock_rdlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _dessert_cli_cmd_logging
/** command "show logging" */
int _dessert_cli_cmd_logging(struct cli_def* cli, char* command, char* argv[], int argc) {
pthread_rwlock_rdlock(&_dessert_logrbuf_len_lock);
int i = 0;
int max = _dessert_logrbuf_len - 1;
char* line;
if(_dessert_logrbuf_len < 1) {
cli_print(
cli,
"logging to ringbuffer is disabled - use \"logging ringbuffer [int]\" in config-mode first");
pthread_rwlock_unlock(&_dessert_logrbuf_len_lock);
return CLI_ERROR;
}
if(argc == 1) {
int max2 = (int) strtol(argv[0], NULL, 10);
if(max2 > 0) {
max = max2;
}
}
/* where to start and print? */
if(max > _dessert_logrbuf_used) {
max = _dessert_logrbuf_used;
}
i = _dessert_logrbuf_cur - max - 1;
if(i < 0) {
i += _dessert_logrbuf_len;
}
while(max > 0) {
i++;
max--;
if(i == _dessert_logrbuf_len) {
i = 0;
}
line = _dessert_logrbuf + (DESSERT_LOGLINE_MAX * i);
cli_print(cli, "%s", line);
}
pthread_rwlock_unlock(&_dessert_logrbuf_len_lock);
return CLI_OK;
}
开发者ID:des-testbed,项目名称:libdessert,代码行数:50,代码来源:dessert_log.c
示例2: rw_lock_read_lock
void rw_lock_read_lock(rw_lock_t* lock)
{
#ifdef __MINGW32__
EnterCriticalSection(&lock->readlock);
EnterCriticalSection(&lock->lock);
lock->readers++;
ResetEvent(lock->writelock);
LeaveCriticalSection(&lock->lock);
LeaveCriticalSection(&lock->readlock);
#else
pthread_rwlock_rdlock(lock);
#endif
}
开发者ID:phsym,项目名称:Simple-NoSQL,代码行数:15,代码来源:concurrency.c
示例3: writer
void * writer() {
for (int i = 0; i < 5; i++) {
pthread_rwlock_rdlock(&rwlock);
pthread_rwlock_trywrlock(&rwlock);
value += 1;
pthread_rwlock_unlock(&rwlock);
sleep(i);
}
pthread_exit(NULL);
}
开发者ID:bodokaiser,项目名称:libuv-internals,代码行数:15,代码来源:rwlock.c
示例4: list_lookup
struct list * list_lookup(int lookup_id)
{
struct list *curr;
int rv;
rv=pthread_rwlock_rdlock(&rw); // 只讀表,因此以讀模式申請讀寫鎖
check_error(rv, "lookup: read lock");
for (curr=list_head; curr !=NULL; curr=curr->next) // 查詢記錄位置
if (curr->id >= lookup_id)
break;
if (curr != NULL && curr->id != lookup_id)
curr = (struct list *)NULL; // 沒有找到
rv = pthread_rwlock_unlock(&rw); // 釋放讀寫鎖
check_error(rv, "add: write unlock");
return (curr);
}
开发者ID:AKSahai,项目名称:Linux_Programming,代码行数:15,代码来源:p13-9.c
示例5: cache_get
static int cache_get(lua_State * L) {
size_t len1,len2;
const char * key_l=lua_tolstring(L,1,&len1);
char * val=NULL;
pthread_rwlock_rdlock(&rwlock);
val=hashtable_get(ht,key_l,&len2);
//printf("%p %s %u\n",val,val,len2);
if(val==NULL) {
pthread_rwlock_unlock(&rwlock);
return 0;
}
lua_pushlstring(L,val,len2);
pthread_rwlock_unlock(&rwlock);
return 1;
}
开发者ID:brenoriba,项目名称:lstage,代码行数:15,代码来源:cache.c
示例6: pthread_rwlock_rdlock
struct gate_info *gate_info_manager_t::get_best_gate_incref(uint64_t uid)
{
struct gate_info *info = NULL;
pthread_rwlock_rdlock(&rwlock);
size_t sz = gate_infos.size();
if (sz > 0) {
int idx = (int)(uid % (uint64_t)sz);
info = gate_infos[idx];
gate_info_incref(info);
}
pthread_rwlock_unlock(&rwlock);
return info;
}
开发者ID:JianchengZh,项目名称:server_src,代码行数:15,代码来源:gate_info.cpp
示例7: runpath_list_fprintf
void runpath_list_fprintf(runpath_list_type * list ) {
pthread_rwlock_rdlock( &list->lock );
{
FILE * stream = util_mkdir_fopen( list->export_file , "w");
const char * line_fmt = runpath_list_get_line_fmt( list );
int index;
vector_sort( list->list , runpath_node_cmp );
for (index =0; index < vector_get_size( list->list ); index++) {
const runpath_node_type * node = runpath_list_iget_node__( list , index );
runpath_node_fprintf( node , line_fmt , stream );
}
fclose( stream );
}
pthread_rwlock_unlock( &list->lock );
}
开发者ID:Ensembles,项目名称:ert,代码行数:15,代码来源:runpath_list.c
示例8: job_find
/*
* Find a job for the given thread ID.
*/
struct job *
job_find(struct queue *qp, pthread_t id)
{
struct job *jp;
if (pthread_rwlock_rdlock(&qp->q_lock) != 0)
return NULL;
for (jp = qp->q_head; jp != NULL; jp = jp->j_next)
if (pthread_equal(jp->j_id, id))
break;
pthread_rwlock_unlock(&qp->q_lock);
return jp;
}
开发者ID:vonzhou,项目名称:Coding,代码行数:18,代码来源:rwlock.c
示例9: pmip_cache_iterate
//---------------------------------------------------------------------------------------------------------------------
int pmip_cache_iterate(int (*func) (void *, void *), void *arg)
{
int err;
int mutex_return_code;
mutex_return_code = pthread_rwlock_rdlock(&pmip_lock);
if (mutex_return_code != 0) {
dbg("pthread_rwlock_rdlock(&pmip_lock) %s\n", strerror(mutex_return_code));
}
err = pmip_hash_iterate(&g_pmip_hash, func, arg);
mutex_return_code = pthread_rwlock_unlock(&pmip_lock);
if (mutex_return_code != 0) {
dbg("pthread_rwlock_unlock(&pmip_lock) %s\n", strerror(mutex_return_code));
}
return err;
}
开发者ID:hugo-ma-alves,项目名称:OAI-PMIPv6-FM,代码行数:16,代码来源:pmip_cache.c
示例10: TSReleaseAssert
void RateLimiter::Release(int counter_index, const char * key, uint64_t amount) {
TSReleaseAssert(!pthread_rwlock_rdlock(&rwlock_keymap_));
std::map<const char *,LimiterState *>::iterator it = keymap_.find(key);
TSReleaseAssert(!pthread_rwlock_unlock(&rwlock_keymap_));
TSReleaseAssert( it != keymap_.end() );
LimiterState * state = it->second;
TSMutexLock(update_mutex_);
state->set_taken(counter_index, state->taken(counter_index) - amount);
dbg("released amount, currently taken %f", state->taken(counter_index));
TSMutexUnlock(update_mutex_);
}
开发者ID:bwahn,项目名称:ats,代码行数:15,代码来源:rate-limiter.cpp
示例11: assert
//---------------------------------------------------------------------------------------------------------------------
pmip_entry_t *pmip_cache_get(const struct in6_addr * our_addr, const struct in6_addr * peer_addr)
{
pmip_entry_t *bce;
assert(peer_addr && our_addr);
pthread_rwlock_rdlock(&pmip_lock);
bce = hash_get(&g_pmip_hash, our_addr, peer_addr);
if (bce) {
pthread_rwlock_wrlock(&bce->lock);
//dbg("PMIP cache entry is found for: %x:%x:%x:%x:%x:%x:%x:%x with type %d\n", NIP6ADDR(&bce->mn_hw_address), (bce->type));
} else {
pthread_rwlock_unlock(&pmip_lock);
//dbg("PMIP cache entry is NOT found for %x:%x:%x:%x:%x:%x:%x:%x <-> %x:%x:%x:%x:%x:%x:%x:%x\n", NIP6ADDR(our_addr), NIP6ADDR(peer_addr));
}
return bce;
}
开发者ID:NetworkingGroupSKKU,项目名称:Buffering-Scheme-in-PMIPv6,代码行数:16,代码来源:pmip_cache.c
示例12: pthread_rwlock_rdlock
/* Looks for the photoset specified in the argument.
* Returns pointer to the stored cached_information
* or 0 if not found.
*/
cached_information *photoset_lookup(const char *photoset) {
cached_photoset *cps;
cached_information *ci_copy = NULL;
pthread_rwlock_rdlock(&cache_lock);
if(check_cache())
goto fail;
cps = g_hash_table_lookup(photoset_ht, photoset);
if(cps)
ci_copy = copy_cached_info(&(cps->ci));
fail: pthread_rwlock_unlock(&cache_lock);
return ci_copy;
}
开发者ID:Xirg,项目名称:FlickrMS,代码行数:19,代码来源:cache.c
示例13: Var_bind
/**
* \brief Bind to a variable
*
* Subscribe to the give variable and automatically populate its value in the float whose reference is passed
*
* \param name Name of the variable to subscribe to
* \param store_to Pointer to a float to store the value of the variable when it is updated
* \return 0 on success
*/
int Var_bind(char* name, float* store_to) {
Subscription* s;
Var_subscribe(name);
pthread_rwlock_rdlock(&subscriptions_lock); {
s = Dictionary_get(subscriptions, name);
s->writeback = store_to;
}
pthread_rwlock_unlock(&subscriptions_lock);
(*s->writeback) = s->current;
return 0;
}
开发者ID:ncsurobotics,项目名称:libseawolf,代码行数:24,代码来源:var.c
示例14: __dcethread_child_fork
static void
__dcethread_child_fork(void)
{
unsigned int i;
pthread_rwlock_rdlock(&atfork_lock);
for (i = 0; i < atfork_handlers_len; i++)
{
if (atfork_handlers[i].child_fork)
atfork_handlers[i].child_fork(atfork_handlers[i].user_state);
}
pthread_rwlock_unlock(&atfork_lock);
}
开发者ID:HumbleRepose,项目名称:dcerpc,代码行数:15,代码来源:dcethread_atfork.c
示例15: rpmlogCtxAcquire
/* Force log context acquisition through a function */
static rpmlogCtx rpmlogCtxAcquire(int write)
{
static struct rpmlogCtx_s _globalCtx = { PTHREAD_RWLOCK_INITIALIZER,
RPMLOG_UPTO(RPMLOG_NOTICE),
0, NULL, NULL, NULL, NULL };
rpmlogCtx ctx = &_globalCtx;
/* XXX: errors should be handled */
if (write)
pthread_rwlock_wrlock(&ctx->lock);
else
pthread_rwlock_rdlock(&ctx->lock);
return ctx;
}
开发者ID:OlegGirko,项目名称:rpm,代码行数:16,代码来源:rpmlog.c
示例16: pthread_rwlock_rdlock
/**
* TryReadLock
*
* This will attempt to aquire the read lock. If it is not able to do so false will be returned.
* If the lock is aquired true will be returned.
*
* If the lock is not aquired you should not make a call to Unlock as the lock is not owned.
**/
bool RWLock::TryReadLock()
{
int ret = pthread_rwlock_rdlock(&m_lock);
if (ret == 0)
return true;
switch(ret)
{
case EBUSY:
return false;
default:
abort();
}
return false;
}
开发者ID:mistralol,项目名称:libclientserver,代码行数:23,代码来源:RWLock.cpp
示例17: glthread_rwlock_rdlock
void
glthread_rwlock_rdlock (gl_rwlock_t *lock)
{
if (!lock->initialized)
{
if (pthread_mutex_lock (&lock->guard) != 0)
abort ();
if (!lock->initialized)
glthread_rwlock_init (lock);
if (pthread_mutex_unlock (&lock->guard) != 0)
abort ();
}
if (pthread_rwlock_rdlock (&lock->rwlock) != 0)
abort ();
}
开发者ID:0Skynet,项目名称:btnx-config,代码行数:15,代码来源:lock.c
示例18: dyn_lock_function
NOEXPORT void dyn_lock_function(int mode, struct CRYPTO_dynlock_value *value,
const char *file, int line) {
(void)file; /* squash the unused parameter warning */
(void)line; /* squash the unused parameter warning */
if(mode&CRYPTO_LOCK) {
/* either CRYPTO_READ or CRYPTO_WRITE (but not both) are needed */
if(!(mode&CRYPTO_READ)==!(mode&CRYPTO_WRITE))
fatal("Invalid locking mode");
if(mode&CRYPTO_WRITE)
pthread_rwlock_wrlock(&value->rwlock);
else
pthread_rwlock_rdlock(&value->rwlock);
} else
pthread_rwlock_unlock(&value->rwlock);
}
开发者ID:NickolasLapp,项目名称:stunnel,代码行数:15,代码来源:sthreads.c
示例19: ucs_async_handler_mode
static ucs_async_mode_t ucs_async_handler_mode(int id)
{
ucs_async_mode_t mode;
khiter_t hash_it;
pthread_rwlock_rdlock(&ucs_async_global_context.handlers_lock);
hash_it = ucs_async_handler_kh_get(id);
if (ucs_async_handler_kh_is_end(hash_it)) {
mode = UCS_ASYNC_MODE_POLL;
} else {
mode = kh_value(&ucs_async_global_context.handlers, hash_it)->mode;
}
pthread_rwlock_unlock(&ucs_async_global_context.handlers_lock);
return mode;
}
开发者ID:alex-mikheev,项目名称:ucx,代码行数:15,代码来源:async.c
示例20: AcquireSRWLockExclusive
void
CPacBioUtility::AcquireLock(bool bExclusive)
{
#ifdef _WIN32
if(bExclusive)
AcquireSRWLockExclusive(&m_hRwLock);
else
AcquireSRWLockShared(&m_hRwLock);
#else
if(bExclusive)
pthread_rwlock_wrlock(&m_hRwLock);
else
pthread_rwlock_rdlock(&m_hRwLock);
#endif
}
开发者ID:ste69r,项目名称:Biokanga,代码行数:15,代码来源:PacBioUtility.cpp
注:本文中的pthread_rwlock_rdlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论