本文整理汇总了C++中rlock函数的典型用法代码示例。如果您正苦于以下问题:C++ rlock函数的具体用法?C++ rlock怎么用?C++ rlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rlock函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lock
void CScheduler::serviceQueue()
{
boost::unique_lock<boost::mutex> lock(newTaskMutex);
++nThreadsServicingQueue;
// newTaskMutex is locked throughout this loop EXCEPT
// when the thread is waiting or when the user's function
// is called.
while (!shouldStop()) {
try {
if (!shouldStop() && taskQueue.empty()) {
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
// Use this chance to get a tiny bit more entropy
RandAddSeedSleep();
}
while (!shouldStop() && taskQueue.empty()) {
// Wait until there is something to do.
newTaskScheduled.wait(lock);
}
// Wait until either there is a new task, or until
// the time of the first item on the queue:
// wait_until needs boost 1.50 or later; older versions have timed_wait:
#if BOOST_VERSION < 105000
while (!shouldStop() && !taskQueue.empty() &&
newTaskScheduled.timed_wait(lock, toPosixTime(taskQueue.begin()->first))) {
// Keep waiting until timeout
}
#else
// Some boost versions have a conflicting overload of wait_until that returns void.
// Explicitly use a template here to avoid hitting that overload.
while (!shouldStop() && !taskQueue.empty()) {
boost::chrono::system_clock::time_point timeToWaitFor = taskQueue.begin()->first;
if (newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout)
break; // Exit loop after timeout, it means we reached the time of the event
}
#endif
// If there are multiple threads, the queue can empty while we're waiting (another
// thread may service the task we were waiting on).
if (shouldStop() || taskQueue.empty())
continue;
Function f = taskQueue.begin()->second;
taskQueue.erase(taskQueue.begin());
{
// Unlock before calling f, so it can reschedule itself or another task
// without deadlocking:
reverse_lock<boost::unique_lock<boost::mutex> > rlock(lock);
f();
}
} catch (...) {
--nThreadsServicingQueue;
throw;
}
}
--nThreadsServicingQueue;
newTaskScheduled.notify_one();
}
开发者ID:DigiByte-Core,项目名称:digibyte,代码行数:60,代码来源:scheduler.cpp
示例2: ipifcregisterproxy
static void
ipifcregisterproxy(Fs *f, Ipifc *ifc, uint8_t *ip)
{
Conv **cp, **e;
Ipifc *nifc;
Iplifc *lifc;
Medium *m;
uint8_t net[IPaddrlen];
/* register the address on any network that will proxy for us */
e = &f->ipifc->conv[f->ipifc->nc];
if(!isv4(ip)) { /* V6 */
for(cp = f->ipifc->conv; cp < e; cp++){
if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
continue;
rlock(nifc);
m = nifc->medium;
if(m == nil || m->addmulti == nil) {
runlock(nifc);
continue;
}
for(lifc = nifc->lifc; lifc; lifc = lifc->next){
maskip(ip, lifc->mask, net);
if(ipcmp(net, lifc->remote) == 0) {
/* add solicited-node multicast addr */
ipv62smcast(net, ip);
addselfcache(f, nifc, lifc, net, Rmulti);
arpenter(f, V6, ip, nifc->mac, 6, 0);
// (*m->addmulti)(nifc, net, ip);
break;
}
}
runlock(nifc);
}
}
else { /* V4 */
for(cp = f->ipifc->conv; cp < e; cp++){
if(*cp == nil || (nifc = (Ipifc*)(*cp)->ptcl) == ifc)
continue;
rlock(nifc);
m = nifc->medium;
if(m == nil || m->areg == nil){
runlock(nifc);
continue;
}
for(lifc = nifc->lifc; lifc; lifc = lifc->next){
maskip(ip, lifc->mask, net);
if(ipcmp(net, lifc->remote) == 0){
(*m->areg)(nifc, ip);
break;
}
}
runlock(nifc);
}
}
}
开发者ID:qioixiy,项目名称:harvey,代码行数:57,代码来源:ipifc.c
示例3: ipifcstate
static int ipifcstate(struct conv *c, char *state, int n)
{
struct Ipifc *ifc;
struct Iplifc *lifc;
int m;
ifc = (struct Ipifc *)c->ptcl;
m = snprintf(state, n, sfixedformat,
ifc->dev, ifc->maxtu, ifc->sendra6, ifc->recvra6,
ifc->rp.mflag, ifc->rp.oflag, ifc->rp.maxraint,
ifc->rp.minraint, ifc->rp.linkmtu, ifc->rp.reachtime,
ifc->rp.rxmitra, ifc->rp.ttl, ifc->rp.routerlt,
ifc->in, ifc->out, ifc->inerr, ifc->outerr);
rlock(&ifc->rwlock);
for (lifc = ifc->lifc; lifc && n > m; lifc = lifc->next)
m += snprintf(state + m, n - m, slineformat,
lifc->local, lifc->mask, lifc->remote,
lifc->validlt, lifc->preflt);
if (ifc->lifc == NULL)
m += snprintf(state + m, n - m, "\n");
runlock(&ifc->rwlock);
return m;
}
开发者ID:7perl,项目名称:akaros,代码行数:25,代码来源:ipifc.c
示例4: nametonum
int
nametonum(char *s)
{
char *p;
int i, lo, hi, m, rv;
s = estrdup(s);
strlower(s);
for(p=s; *p; p++)
if(*p=='_')
*p = ' ';
currentmap(0);
rlock(&maplock);
lo = 0;
hi = map->nel;
while(hi-lo > 1){
m = (lo+hi)/2;
i = strcmp(s, map->el[m].s);
if(i < 0)
hi = m;
else
lo = m;
}
if(hi-lo == 1 && strcmp(s, map->el[lo].s)==0)
rv = map->el[lo].n;
else
rv = -1;
runlock(&maplock);
free(s);
return rv;
}
开发者ID:bhanug,项目名称:harvey,代码行数:32,代码来源:io.c
示例5: envcpy
void
envcpy(Egrp *to, Egrp *from)
{
int i;
Evalue *ne, *e;
rlock(&from->rwl);
to->ment = (from->nent+31)&~31;
to->ent = smalloc(to->ment*sizeof(to->ent[0]));
for(i=0; i<from->nent; i++){
e = from->ent[i];
ne = smalloc(sizeof(Evalue));
ne->name = smalloc(strlen(e->name)+1);
strcpy(ne->name, e->name);
if(e->value){
ne->value = smalloc(e->len);
memmove(ne->value, e->value, e->len);
ne->len = e->len;
}
ne->qid.path = ++to->path;
to->ent[i] = ne;
}
to->nent = from->nent;
runlock(&from->rwl);
}
开发者ID:Requaos,项目名称:harvey,代码行数:25,代码来源:devenv.c
示例6: cmd_sync
void
cmd_sync(void)
{
rlock(&mainlock);
syncall();
runlock(&mainlock);
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:7,代码来源:con.c
示例7: walkfile1
static File*
walkfile1(File *dir, char *elem)
{
File *fp;
Filelist *fl;
rlock(&dir->RWLock);
if(strcmp(elem, "..") == 0){
fp = dir->parent;
incref(&fp->Ref);
runlock(&dir->RWLock);
closefile(dir);
return fp;
}
fp = nil;
for(fl=dir->filelist; fl; fl=fl->link)
if(fl->f && strcmp(fl->f->Dir.name, elem)==0){
fp = fl->f;
incref(&fp->Ref);
break;
}
runlock(&dir->RWLock);
closefile(dir);
return fp;
}
开发者ID:dancrossnyc,项目名称:harvey,代码行数:27,代码来源:file.c
示例8: envgen
static int
envgen(Chan *c, char *name, Dirtab* dir, int i, int s, Dir *dp)
{
Proc *up = externup();
Egrp *eg;
Evalue *e;
if(s == DEVDOTDOT){
devdir(c, c->qid, "#e", 0, eve, DMDIR|0775, dp);
return 1;
}
eg = envgrp(c);
rlock(&eg->rwl);
e = 0;
if(name)
e = envlookup(eg, name, -1);
else if(s < eg->nent)
e = eg->ent[s];
if(e == 0) {
runlock(&eg->rwl);
return -1;
}
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, e->name, sizeof up->genbuf);
devdir(c, e->qid, up->genbuf, e->len, eve, 0666, dp);
runlock(&eg->rwl);
return 1;
}
开发者ID:Requaos,项目名称:harvey,代码行数:31,代码来源:devenv.c
示例9: mntscan
static void
mntscan(Mntwalk *mw, Pgrp *pg)
{
Mount *t;
Mhead *f;
int nxt, i;
ulong last, bestmid;
rlock(&pg->ns);
nxt = 0;
bestmid = ~0;
last = 0;
if(mw->mh)
last = mw->cm->mountid;
for(i = 0; i < MNTHASH; i++) {
for(f = pg->mnthash[i]; f; f = f->hash) {
for(t = f->mount; t; t = t->next) {
if(mw->mh == 0 ||
(t->mountid > last && t->mountid < bestmid)) {
mw->cm = t;
mw->mh = f;
bestmid = mw->cm->mountid;
nxt = 1;
}
}
}
}
if(nxt == 0)
mw->mh = 0;
runlock(&pg->ns);
}
开发者ID:8l,项目名称:inferno,代码行数:35,代码来源:devprog.c
示例10: envread
static int32_t
envread(Chan *c, void *a, int32_t n, int64_t off)
{
Egrp *eg;
Evalue *e;
int32_t offset;
if(c->qid.type & QTDIR)
return devdirread(c, a, n, 0, 0, envgen);
eg = envgrp(c);
rlock(&eg->rwl);
e = envlookup(eg, nil, c->qid.path);
if(e == 0) {
runlock(&eg->rwl);
error(Enonexist);
}
offset = off;
if(offset > e->len) /* protects against overflow converting int64_t to long */
n = 0;
else if(offset + n > e->len)
n = e->len - offset;
if(n <= 0)
n = 0;
else
memmove(a, e->value+offset, n);
runlock(&eg->rwl);
return n;
}
开发者ID:Requaos,项目名称:harvey,代码行数:30,代码来源:devenv.c
示例11: switch
void LIRGenerator::do_Convert(Convert* x) {
// flags that vary for the different operations and different SSE-settings
bool fixed_input, fixed_result, round_result, needs_stub;
switch (x->op()) {
case Bytecodes::_i2l: // fall through
case Bytecodes::_l2i: // fall through
case Bytecodes::_i2b: // fall through
case Bytecodes::_i2c: // fall through
case Bytecodes::_i2s: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_f2d: fixed_input = UseSSE == 1; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_d2f: fixed_input = false; fixed_result = UseSSE == 1; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_i2f: fixed_input = false; fixed_result = false; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_i2d: fixed_input = false; fixed_result = false; round_result = false; needs_stub = false; break;
case Bytecodes::_f2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break;
case Bytecodes::_d2i: fixed_input = false; fixed_result = false; round_result = false; needs_stub = true; break;
case Bytecodes::_l2f: fixed_input = false; fixed_result = UseSSE >= 1; round_result = UseSSE < 1; needs_stub = false; break;
case Bytecodes::_l2d: fixed_input = false; fixed_result = UseSSE >= 2; round_result = UseSSE < 2; needs_stub = false; break;
case Bytecodes::_f2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break;
case Bytecodes::_d2l: fixed_input = true; fixed_result = true; round_result = false; needs_stub = false; break;
default: ShouldNotReachHere();
}
LIRItem value(x->value(), this);
value.load_item();
LIR_Opr input = value.result();
LIR_Opr result = rlock(x);
// arguments of lir_convert
LIR_Opr conv_input = input;
LIR_Opr conv_result = result;
ConversionStub* stub = NULL;
if (fixed_input) {
conv_input = fixed_register_for(input->type());
__ move(input, conv_input);
}
assert(fixed_result == false || round_result == false, "cannot set both");
if (fixed_result) {
conv_result = fixed_register_for(result->type());
} else if (round_result) {
result = new_register(result->type());
set_vreg_flag(result, must_start_in_memory);
}
if (needs_stub) {
stub = new ConversionStub(x->op(), conv_input, conv_result);
}
__ convert(x->op(), conv_input, conv_result, stub);
if (result != conv_result) {
__ move(conv_result, result);
}
assert(result->is_virtual(), "result must be virtual register");
set_result(x, result);
}
开发者ID:ericbbcc,项目名称:hotspot,代码行数:60,代码来源:c1_LIRGenerator_x86.cpp
示例12: envread
static long
envread(Chan *c, void *a, long n, vlong off)
{
Egrp *eg;
Evalue *e;
ulong offset = off;
if(c->qid.type & QTDIR)
return devdirread(c, a, n, 0, 0, envgen);
eg = envgrp(c);
rlock(eg);
if(waserror()){
runlock(eg);
nexterror();
}
e = envlookup(eg, nil, c->qid.path);
if(e == nil)
error(Enonexist);
if(offset >= e->len || e->value == nil)
n = 0;
else if(offset + n > e->len)
n = e->len - offset;
if(n <= 0)
n = 0;
else
memmove(a, e->value+offset, n);
runlock(eg);
poperror();
return n;
}
开发者ID:srk-cmu,项目名称:9problems,代码行数:33,代码来源:devenv.c
示例13: log_debug
Component& Comploader::fetchComp(const Compident& ci,
const Urlmapper& rootmapper)
{
log_debug("fetchComp \"" << ci << '"');
cxxtools::ReadLock rlock(mutex);
cxxtools::WriteLock wlock(mutex, false);
// lookup Component
componentmap_type::iterator it = componentmap.find(ci);
if (it == componentmap.end())
{
rlock.unlock();
wlock.lock();
it = componentmap.find(ci);
if (it == componentmap.end())
{
ComponentLibrary& lib = fetchLib(ci.libname);
Component* comp = lib.create(ci.compname, *this, rootmapper);
componentmap[ci] = comp;
return *comp;
}
}
return *(it->second);
}
开发者ID:913862627,项目名称:tntnet,代码行数:27,代码来源:comploader.cpp
示例14: envgen
static int
envgen(Chan *c, char *name, Dirtab*, int, int s, Dir *dp)
{
Egrp *eg;
Evalue *e;
if(s == DEVDOTDOT){
devdir(c, c->qid, "#e", 0, eve, DMDIR|0775, dp);
return 1;
}
eg = envgrp(c);
rlock(eg);
if(name != nil)
e = envlookup(eg, name, -1);
else if(s < eg->nent)
e = &eg->ent[s];
else
e = nil;
if(e == nil || name != nil && (strlen(e->name) >= sizeof(up->genbuf))) {
runlock(eg);
return -1;
}
/* make sure name string continues to exist after we release lock */
kstrcpy(up->genbuf, e->name, sizeof up->genbuf);
devdir(c, e->qid, up->genbuf, e->len, eve, 0666, dp);
runlock(eg);
return 1;
}
开发者ID:srk-cmu,项目名称:9problems,代码行数:30,代码来源:devenv.c
示例15: fs_chaninit
/*
* allocate 'count' contiguous channels
* of type 'type' and return pointer to base
*/
Chan*
fs_chaninit(int type, int count, int data)
{
uint8_t *p;
Chan *cp, *icp;
int i;
p = malloc(count * (sizeof(Chan)+data));
icp = (Chan*)p;
for(i = 0; i < count; i++) {
cp = (Chan*)p;
cp->next = chans;
chans = cp;
cp->type = type;
cp->chan = cons.chano;
cons.chano++;
strncpy(cp->whoname, "<none>", sizeof cp->whoname);
wlock(&cp->reflock);
wunlock(&cp->reflock);
rlock(&cp->reflock);
runlock(&cp->reflock);
p += sizeof(Chan);
if(data){
cp->pdata = p;
p += data;
}
}
return icp;
}
开发者ID:npe9,项目名称:harvey,代码行数:34,代码来源:sub.c
示例16: void
void Config::scheduledQueries(std::function<
void(const std::string& name, const ScheduledQuery& query)> predicate) {
ReadLock rlock(config_schedule_mutex_);
for (Pack& pack : *schedule_) {
for (const auto& it : pack.getSchedule()) {
std::string name = it.first;
// The query name may be synthetic.
if (pack.getName() != "main" && pack.getName() != "legacy_main") {
name = "pack" + FLAGS_pack_delimiter + pack.getName() +
FLAGS_pack_delimiter + it.first;
}
// They query may have failed and been added to the schedule's blacklist.
if (schedule_->blacklist_.count(name) > 0) {
auto blacklisted_query = schedule_->blacklist_.find(name);
if (getUnixTime() > blacklisted_query->second) {
// The blacklisted query passed the expiration time (remove).
schedule_->blacklist_.erase(blacklisted_query);
saveScheduleBlacklist(schedule_->blacklist_);
} else {
// The query is still blacklisted.
continue;
}
}
// Call the predicate.
predicate(name, it.second);
}
}
}
开发者ID:tburgin,项目名称:osquery,代码行数:28,代码来源:config.cpp
示例17: serve
/*
* main filesystem server loop.
* entered by many processes.
* they wait for message buffers and
* then process them.
*/
void
serve(void *)
{
int i;
Chan *cp;
Msgbuf *mb;
for (;;) {
qlock(&reflock);
/* read 9P request from a network input process */
mb = fs_recv(serveq, 0);
assert(mb->magic == Mbmagic);
/* fs kernel sets chan in /sys/src/fs/ip/il.c:/^getchan */
cp = mb->chan;
if (cp == nil)
panic("serve: nil mb->chan");
rlock(&cp->reflock);
qunlock(&reflock);
rlock(&mainlock);
if (mb->data == nil)
panic("serve: nil mb->data");
/* better sniffing code in /sys/src/cmd/disk/kfs/9p12.c */
if(cp->protocol == nil){
/* do we recognise the protocol in this packet? */
/* better sniffing code: /sys/src/cmd/disk/kfs/9p12.c */
for(i = 0; fsprotocol[i] != nil; i++)
if(fsprotocol[i](mb) != 0) {
cp->protocol = fsprotocol[i];
break;
}
if(cp->protocol == nil){
print("no protocol for message\n");
for(i = 0; i < 12; i++)
print(" %2.2X", mb->data[i]);
print("\n");
}
} else
/* process the request, generate an answer and reply */
cp->protocol(mb);
mbfree(mb);
runlock(&mainlock);
runlock(&cp->reflock);
}
}
开发者ID:Requaos,项目名称:harvey,代码行数:53,代码来源:main.c
示例18: lock_release
int
lock_release(lock_t *lock) {
/*int* a;
int t =10;
a=&t;*/
rlock(lock);
return -1;
}
开发者ID:manavgarg,项目名称:Intro-to-Operating-Systens---CS537,代码行数:8,代码来源:ulib.c
示例19: rlock
void Config::getPerformanceStats(
const std::string& name,
std::function<void(const QueryPerformance& query)> predicate) {
if (performance_.count(name) > 0) {
ReadLock rlock(config_performance_mutex_);
predicate(performance_.at(name));
}
}
开发者ID:tburgin,项目名称:osquery,代码行数:8,代码来源:config.cpp
示例20: rlock
/*public */void ASDDeviceTransceiver::getData(DataRec* result) const
{
if (result != NULL) {
boost::shared_lock<boost::shared_mutex> rlock(_mutex);
*result = _data;
}
return;
}
开发者ID:ARTSAT,项目名称:ground_station,代码行数:8,代码来源:ASDDeviceTransceiver.cpp
注:本文中的rlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论