这篇教程C++ wlock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wlock函数的典型用法代码示例。如果您正苦于以下问题:C++ wlock函数的具体用法?C++ wlock怎么用?C++ wlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wlock函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: consopenstatic Chan*consopen(Chan *c, int omode){ c = devopen(c, omode, contab, nelem(contab), devgen); switch((ulong)c->qid.path) { case Qconsctl: incref(&kbd.ctl); break; case Qscancode: qlock(&kbd.gq); if(gkscanq != nil || gkscanid == nil) { qunlock(&kbd.q); c->flag &= ~COPEN; if(gkscanq) error(Einuse); else error("not supported"); } gkscanq = qopen(256, 0, nil, nil); qunlock(&kbd.gq); break; case Qkprint: wlock(&kprintq.l); if(waserror()){ wunlock(&kprintq.l); c->flag &= ~COPEN; nexterror(); } if(kprintq.q != nil) error(Einuse); kprintq.q = qopen(32*1024, Qcoalesce, nil, nil); if(kprintq.q == nil) error(Enomem); qnoblock(kprintq.q, 1); poperror(); wunlock(&kprintq.l); c->iounit = qiomaxatomic; break; case Qevents: c->aux = qopen(512, 0, nil, nil); add_listener(&event_listeners, c->aux); break; } return c;}
开发者ID:8l,项目名称:inferno,代码行数:47,
示例2: wlockvoid Config::recordQueryPerformance(const std::string& name, size_t delay, size_t size, const Row& r0, const Row& r1) { WriteLock wlock(config_performance_mutex_); if (performance_.count(name) == 0) { performance_[name] = QueryPerformance(); } // Grab access to the non-const schedule item. auto& query = performance_.at(name); BIGINT_LITERAL diff = 0; if (!r1.at("user_time").empty() && !r0.at("user_time").empty()) { diff = AS_LITERAL(BIGINT_LITERAL, r1.at("user_time")) - AS_LITERAL(BIGINT_LITERAL, r0.at("user_time")); if (diff > 0) { query.user_time += diff; } } if (!r1.at("system_time").empty() && !r0.at("system_time").empty()) { diff = AS_LITERAL(BIGINT_LITERAL, r1.at("system_time")) - AS_LITERAL(BIGINT_LITERAL, r0.at("system_time")); if (diff > 0) { query.system_time += diff; } } if (!r1.at("resident_size").empty() && !r0.at("resident_size").empty()) { diff = AS_LITERAL(BIGINT_LITERAL, r1.at("resident_size")) - AS_LITERAL(BIGINT_LITERAL, r0.at("resident_size")); if (diff > 0) { // Memory is stored as an average of RSS changes between query executions. query.average_memory = (query.average_memory * query.executions) + diff; query.average_memory = (query.average_memory / (query.executions + 1)); } } query.wall_time += delay; query.output_size += size; query.executions += 1; query.last_executed = getUnixTime(); // Clear the executing query (remove the dirty bit). setDatabaseValue(kPersistentSettings, kExecutingQuery, "");}
开发者ID:zcourts,项目名称:osquery,代码行数:47,
示例3: wlockvoid testObj::test<5>(void){ WaitingLockData wld; volatile int state=0; auto_ptr<WriteLock> wlock( new WriteLock(mutexRW_) ); assert( wlock.get()!=NULL ); TestThread tt(&wld, &state, &mutexRW_); thread th(tt); // wait for thread a little const TimeoutChecker tc(5, "timed out while waiting for state to change"); while( state!=1 && tc() ) boost::thread::yield(); // release lock by setting new value wld.setPtr( leaf_.shared_ptr() ); // join - if call exited, thread will join cleanly th.join();}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:17,
示例4: report_titlestatic int report_title(const char *fmt,...){ int len = 0; if ( report_fp ) { wlock(&report_lock); if ( report_cols++>0 ) len = fprintf(report_fp,"%s",report_eol); va_list ptr; va_start(ptr,fmt); len = +vfprintf(report_fp,fmt,ptr); va_end(ptr); fflush(report_fp); wunlock(&report_lock); } return len;}
开发者ID:AMFIRNAS,项目名称:wso2-gridlabd,代码行数:17,
示例5: wlockbool WorldDownloadManager::lockKinfu(){ boost::mutex::scoped_lock wlock(m_kinfu_waiting_mutex); m_kinfu_waiting_count++; // wake up the kinfu thread, so "respond" may be called m_shared_cond.notify_one(); while (!m_kinfu_available && !m_is_shutting_down) m_kinfu_waiting_cond.wait(wlock); if (m_is_shutting_down) return false; m_kinfu_available = false; return true;}
开发者ID:caomw,项目名称:ros_kinfu,代码行数:17,
示例6: ipifcunbind/* * detach a device from an interface, close the interface * called with ifc->conv closed */static char*ipifcunbind(Ipifc *ifc){ Proc *up = externup(); char *err; if(waserror()){ wunlock(ifc); nexterror(); } wlock(ifc); /* dissociate routes */ if(ifc->medium != nil && ifc->medium->unbindonclose == 0) ifc->conv->inuse--; ifc->ifcid++; /* disassociate logical interfaces (before zeroing ifc->arg) */ while(ifc->lifc){ err = ipifcremlifc(ifc, ifc->lifc); /* * note: err non-zero means lifc not found, * which can't happen in this case. */ if(err) error(err); } /* disassociate device */ if(ifc->medium && ifc->medium->unbind) (*ifc->medium->unbind)(ifc); memset(ifc->dev, 0, sizeof(ifc->dev)); ifc->arg = nil; ifc->reassemble = 0; /* close queues to stop queuing of packets */ qclose(ifc->conv->rq); qclose(ifc->conv->wq); qclose(ifc->conv->sq); ifc->medium = nil; wunlock(ifc); poperror(); return nil;}
开发者ID:qioixiy,项目名称:harvey,代码行数:49,
示例7: consinitvoidconsinit(void){ int i; cons.chan = ialloc(sizeof(Chan)); wlock(&cons.chan->reflock); wunlock(&cons.chan->reflock); lock(&cons.chan->flock); unlock(&cons.chan->flock); dofilter(&cons.work); dofilter(&cons.rate); dofilter(&cons.bhit); dofilter(&cons.bread); dofilter(&cons.binit); for(i = 0; i < MAXTAG; i++) dofilter(&cons.tags[i]);}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:18,
示例8: mainint main(){ printf("进程标识(PID): %d/n",getpid()); int fd = open("lock.txt",O_RDWR | O_CREAT | O_TRUNC,0664); if(fd == -1){ perror("open"); return -1; } const char* text = "ABCDEFGHIJKLMNOPQR"; if(write(fd,text,strlen(text) * sizeof(text[0])) == -1){ perror("write"); return -1; } //对EFGH加读锁 printf("对EFGH加读锁"); //文件头从0开始 if(rlock(fd,4,4,0) == -1){ printf("失败:%m/n"); return -1; } printf("成功!/n"); //对MNOP加写锁 printf("对MNOP加写锁"); if(wlock(fd,12,4,0) == -1){ printf("失败:%m/n"); return -1; } printf("成功!/n"); printf("按<回车>,解锁MN..."); getchar(); //解锁MN ulock(fd,12,2); printf("按<回车>,解锁EFGH..."); getchar(); //解锁EFGH ulock(fd,4,4); /** * 只要文件描述符一关,什么锁就都没有了。系统内核会自动为你解锁,文件表会被删掉 * 你加的锁也会从v节点表的锁的链表中删掉 * 因为只要文件描述符一关,文件描述符和文件指针的对应就会被删掉, * 文件表也就没有了,对应v节点表中的锁的链表也就没有了 */ close(fd); return 0;}
开发者ID:nannanwuhui,项目名称:C,代码行数:44,
示例9: envopenstatic Chan*envopen(Chan *c, int omode){ Egrp *eg; Evalue *e; int trunc; eg = envgrp(c); if(c->qid.type & QTDIR) { if(omode != OREAD) error(Eperm); } else { trunc = omode & OTRUNC; if(omode != OREAD && !envwriteable(c)) error(Eperm); if(trunc) wlock(&eg->rwl); else rlock(&eg->rwl); e = envlookup(eg, nil, c->qid.path); if(e == 0) { if(trunc) wunlock(&eg->rwl); else runlock(&eg->rwl); error(Enonexist); } if(trunc && e->value) { e->qid.vers++; free(e->value); e->value = 0; e->len = 0; } if(trunc) wunlock(&eg->rwl); else runlock(&eg->rwl); } c->mode = openmode(omode); c->flag |= COPEN; c->offset = 0; return c;}
开发者ID:Requaos,项目名称:harvey,代码行数:44,
示例10: wlockDocument *Cache::get( const Key &key ){ Status::cacheReqRetain(); wlock(); Document *doc = data[key.str()]; if ( doc && list.front() != doc ) { std::list<Document*>::iterator it = std::find( list.begin(), list.end(), doc ); list.erase( it ); list.push_front( doc ); } unlock(); if ( doc ) Status::cacheHitRetain(); return doc;}
开发者ID:kibae,项目名称:defer.io,代码行数:19,
示例11: voidcachevoidvoidcache(int n){ Wcache *c; rlock(&cachelock); if(c = findcache(n)){ wlock(c); c->tcurrent = 0; c->thist = 0; /* aggressively free memory */ closewhist(c->hist); c->hist = nil; closewhist(c->current); c->current = nil; wunlock(c); } runlock(&cachelock);}
开发者ID:bhanug,项目名称:harvey,代码行数:19,
示例12: alockHRESULT SystemProperties::getDefaultAdditionsISO(com::Utf8Str &aDefaultAdditionsISO){ AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); if (m->strDefaultAdditionsISO.isEmpty()) { /* no guest additions, check if it showed up in the mean time */ alock.release(); { AutoWriteLock wlock(this COMMA_LOCKVAL_SRC_POS); ErrorInfoKeeper eik; (void)setDefaultAdditionsISO(""); } alock.acquire(); } aDefaultAdditionsISO = m->strDefaultAdditionsISO; return S_OK;}
开发者ID:jeppeter,项目名称:vbox,代码行数:19,
示例13: envwritestatic longenvwrite(Chan *c, void *a, long n, vlong off){ char *s; ulong len; Egrp *eg; Evalue *e; ulong offset = off; if(n <= 0) return 0; if(offset > Maxenvsize || n > (Maxenvsize - offset)) error(Etoobig); eg = envgrp(c); wlock(eg); if(waserror()){ wunlock(eg); nexterror(); } e = envlookup(eg, nil, c->qid.path); if(e == nil) error(Enonexist); len = offset+n; if(len > e->len) { s = realloc(e->value, len); if(s == nil) error(Enomem); memset(s+offset, 0, n); e->value = s; e->len = len; } memmove(e->value+offset, a, n); e->qid.vers++; eg->vers++; wunlock(eg); poperror(); return n;}
开发者ID:srk-cmu,项目名称:9problems,代码行数:42,
示例14: renew void renew() { com::xiaonei::xce::Statement sql; sql << "SELECT * FROM " << TABLE_CONFIG; std::map<std::string, ConfigItemPtr> config; BatchDbResultHandler handler(config); com::xiaonei::xce::QueryRunner(DB_CONFIG, com::xiaonei::xce::CDbRServer).query(sql, handler); std::vector<std::string> vecStr; for(std::map<std::string, ConfigItemPtr>::const_iterator it = config.begin(); it != config.end(); ++it) { vecStr.push_back(it->first); } if(!config.empty()) { IceUtil::RWRecMutex::WLock wlock(rwMutex_); config_.swap(config); dbTableVec_.swap(vecStr); } }
开发者ID:gunner14,项目名称:old_rr_code,代码行数:20,
示例15: wlockPendingCollection::LockedPtr PendingCollection::lockAndWait( std::chrono::milliseconds timeoutms, bool& pinged) { auto lock = wlock(); if (lock->checkAndResetPinged()) { pinged = true; return lock; } if (timeoutms.count() == -1) { cond_.wait(lock.getUniqueLock()); } else { cond_.wait_for(lock.getUniqueLock(), timeoutms); } pinged = lock->checkAndResetPinged(); return lock;}
开发者ID:danez,项目名称:watchman,代码行数:20,
示例16: ipifcremmulti/* * remove a multicast address from an interface, called with c locked */void ipifcremmulti(struct conv *c, uint8_t * ma, uint8_t * ia){ ERRSTACK(1); struct Ipmulti *multi, **l; struct Iplifc *lifc; struct conv **p; struct Ipifc *ifc; struct Fs *f; f = c->p->f; for (l = &c->multi; *l; l = &(*l)->next) if (ipcmp(ma, (*l)->ma) == 0) if (ipcmp(ia, (*l)->ia) == 0) break; multi = *l; if (multi == NULL) return; /* we don't have it open */ *l = multi->next; for (p = f->ipifc->conv; *p; p++) { if ((*p)->inuse == 0) continue; ifc = (struct Ipifc *)(*p)->ptcl; if (waserror()) { wunlock(&ifc->rwlock); nexterror(); } wlock(&ifc->rwlock); for (lifc = ifc->lifc; lifc; lifc = lifc->next) if (ipcmp(ia, lifc->local) == 0) remselfcache(f, ifc, lifc, ma); wunlock(&ifc->rwlock); poperror(); } kfree(multi);}
开发者ID:7perl,项目名称:akaros,代码行数:44,
示例17: ipifcremmulti/* * remove a multicast address from an interface, called with c->car locked */voidipifcremmulti(Conv *c, uint8_t *ma, uint8_t *ia){ Proc *up = externup(); Ipmulti *multi, **l; Iplifc *lifc; Conv **p; Ipifc *ifc; Fs *f; f = c->p->f; for(l = &c->multi; *l; l = &(*l)->next) if(ipcmp(ma, (*l)->ma) == 0 && ipcmp(ia, (*l)->ia) == 0) break; multi = *l; if(multi == nil) return; /* we don't have it open */ *l = multi->next; for(p = f->ipifc->conv; *p; p++){ if((*p)->inuse == 0) continue; ifc = (Ipifc*)(*p)->ptcl; if(waserror()){ wunlock(ifc); nexterror(); } wlock(ifc); for(lifc = ifc->lifc; lifc; lifc = lifc->next) if(ipcmp(ia, lifc->local) == 0) remselfcache(f, ifc, lifc, ma); wunlock(ifc); poperror(); } free(multi);}
开发者ID:qioixiy,项目名称:harvey,代码行数:44,
示例18: consclosestatic voidconsclose(Chan *c){ if((c->flag&COPEN) == 0) return; switch((ulong)c->qid.path){ case Qconsctl: /* last close of control file turns off raw */ qlock(&kbd); if(--kbd.ctl == 0) kbd.raw = 0; qunlock(&kbd); break; case Qkeyboard: if(c->mode != OWRITE) { qlock(&kbd); --kbd.kbdr; qunlock(&kbd); } break; case Qscancode: qlock(&kbd); if(kscanq) { qfree(kscanq); kscanq = 0; } qunlock(&kbd); break; case Qkprint: wlock(&kprintq); qfree(kprintq.q); kprintq.q = nil; wunlock(&kprintq); break; }}
开发者ID:8l,项目名称:inferno,代码行数:40,
示例19: ERRSTACK/* * detach a device from an interface, close the interface * called with ifc->conv closed */static char *ipifcunbind(struct Ipifc *ifc){ ERRSTACK(1); char *err; if (waserror()) { wunlock(&ifc->rwlock); nexterror(); } wlock(&ifc->rwlock); /* dissociate routes */ if (ifc->m != NULL && ifc->m->unbindonclose == 0) ifc->conv->inuse--; ifc->ifcid++; /* disassociate device */ if (ifc->m != NULL && ifc->m->unbind) (*ifc->m->unbind) (ifc); memset(ifc->dev, 0, sizeof(ifc->dev)); ifc->arg = NULL; ifc->reassemble = 0; /* close queues to stop queuing of packets */ qclose(ifc->conv->rq); qclose(ifc->conv->wq); qclose(ifc->conv->sq); /* disassociate logical interfaces */ while (ifc->lifc) { err = ipifcremlifc(ifc, ifc->lifc); if (err) error(err); } ifc->m = NULL; wunlock(&ifc->rwlock); poperror(); return NULL;}
开发者ID:7perl,项目名称:akaros,代码行数:44,
示例20: MCE_INFOvoid FeedMcProxyConsumer::update(const string& shard, const vector<string>& endpoints) { MCE_INFO("FeedMcProxyConsumer::update --> shard:" << shard); vector<string> tmp(endpoints); boost::unique_lock<boost::shared_mutex> wlock(mutex_); map<string, vector<string> >::iterator it = endpoints_.find(shard); if (it != endpoints_.end()) { it->second.swap(tmp); if (!it->second.empty()) { try { string endpoints; for (size_t i = 0; i<it->second.size(); ++i) { endpoints += it->second[i] + ";"; } LoadCluster(it->first,endpoints); } catch(std::exception& e) { MCE_WARN("FeedMcProxyConsumer::update -->err," << e.what()); } } }}
开发者ID:gunner14,项目名称:old_rr_code,代码行数:22,
示例21: envremovestatic voidenvremove(Chan *c){ Egrp *eg; Evalue *e; if(c->qid.type & QTDIR || !envwriteable(c)) error(Eperm); eg = envgrp(c); wlock(eg); e = envlookup(eg, nil, c->qid.path); if(e == nil){ wunlock(eg); error(Enonexist); } free(e->name); free(e->value); *e = eg->ent[--eg->nent]; eg->vers++; wunlock(eg);}
开发者ID:srk-cmu,项目名称:9problems,代码行数:22,
示例22: devrecovervoiddevrecover(Device *d){ for (;;) { print("recover: %Z/n", d); switch(d->type) { default: print("recover: unknown dev type %Z/n", d); return; case Devcw: wlock(&mainlock); /* recover */ cwrecover(d); wunlock(&mainlock); return; case Devswab: d = d->swab.d; break; } }}
开发者ID:npe9,项目名称:harvey,代码行数:22,
示例23: caninsertkeyintcaninsertkey(Intmap *map, ulong id, void *v){ Intlist *f; int rv; ulong h; wlock(map); if(*llookup(map, id)) rv = 0; else{ f = emalloc9p(sizeof *f); f->id = id; f->aux = v; h = hashid(id); f->link = map->hash[h]; map->hash[h] = f; rv = 1; } wunlock(map); return rv; }
开发者ID:AustenConrad,项目名称:plan-9,代码行数:22,
示例24: envwritestatic int32_tenvwrite(Chan *c, void *a, int32_t n, int64_t off){ char *s; Egrp *eg; Evalue *e; int32_t len, offset; if(n <= 0) return 0; offset = off; if(offset > Maxenvsize || n > (Maxenvsize - offset)) error(Etoobig); eg = envgrp(c); wlock(&eg->rwl); e = envlookup(eg, nil, c->qid.path); if(e == 0) { wunlock(&eg->rwl); error(Enonexist); } len = offset+n; if(len > e->len) { s = smalloc(len); if(e->value){ memmove(s, e->value, e->len); free(e->value); } e->value = s; e->len = len; } memmove(e->value+offset, a, n); e->qid.vers++; eg->vers++; wunlock(&eg->rwl); return n;}
开发者ID:Requaos,项目名称:harvey,代码行数:38,
示例25: THROW/** Establish the default timezone for time conversion. /p NULL /p tzname uses /p TZ environment for default **/char *timestamp_set_tz(char *tz_name){ if (tz_name == NULL){ tz_name=getenv("TZ"); } if(tz_name == NULL) { static char guess[64]; static unsigned int tzlock=0; if (strcmp(_tzname[0], "") == 0){ THROW("timezone not identified"); /* TROUBLESHOOT An attempt to use timezones was made before the timezome has been specified. Try adding or moving the timezone spec to the top of the <code>clock</code> directive and try again. Alternatively, you can set the '''TZ''' environment variable. */ } wlock(&tzlock); if (_timezone % 60 == 0){ sprintf(guess, "%s%d%s", _tzname[0], (int)(_timezone / 3600), _daylight?_tzname[1]:""); } else { sprintf(guess, "%s%d:%d%s", _tzname[0], (int)(_timezone / 3600), (int)(_timezone / 60), _daylight?_tzname[1]:""); } if (_timezone==0 && _daylight==0) tz_name="UTC0"; else tz_name = guess; wunlock(&tzlock); } load_tzspecs(tz_name); return current_tzname;}
开发者ID:brennane,项目名称:gridpot,代码行数:41,
示例26: report_openstatic bool report_open(void){ wlock(&report_lock); global_getvar("validate_report",report_file,sizeof(report_file)); if ( report_fp==NULL ) { report_ext = strrchr(report_file,'.'); if ( strcmp(report_ext,".csv")==0 ) { report_col = ","; report_eot = "/n"; } else if ( strcmp(report_ext,".txt")==0) { report_col = "/t"; report_eot = "/n"; } report_fp = fopen(report_file,"w"); } wunlock(&report_lock); return report_fp!=NULL;}
开发者ID:AMFIRNAS,项目名称:wso2-gridlabd,代码行数:23,
注:本文中的wlock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wlog函数代码示例 C++ wldev_mkiovar函数代码示例 |