本文整理汇总了C++中Guard类的典型用法代码示例。如果您正苦于以下问题:C++ Guard类的具体用法?C++ Guard怎么用?C++ Guard使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: p2i
void GuardedMemory::print_on(outputStream* st) const {
if (_base_addr == NULL) {
st->print_cr("GuardedMemory(" PTR_FORMAT ") not associated to any memory", p2i(this));
return;
}
st->print_cr("GuardedMemory(" PTR_FORMAT ") base_addr=" PTR_FORMAT
" tag=" PTR_FORMAT " user_size=" SIZE_FORMAT " user_data=" PTR_FORMAT,
p2i(this), p2i(_base_addr), p2i(get_tag()), get_user_size(), p2i(get_user_ptr()));
Guard* guard = get_head_guard();
st->print_cr(" Header guard @" PTR_FORMAT " is %s", p2i(guard), (guard->verify() ? "OK" : "BROKEN"));
guard = get_tail_guard();
st->print_cr(" Trailer guard @" PTR_FORMAT " is %s", p2i(guard), (guard->verify() ? "OK" : "BROKEN"));
u_char udata = *get_user_ptr();
switch (udata) {
case uninitBlockPad:
st->print_cr(" User data appears unused");
break;
case freeBlockPad:
st->print_cr(" User data appears to have been freed");
break;
default:
st->print_cr(" User data appears to be in use");
break;
}
}
示例2: EnsureUnicity
list<vector<Element> > Guard::getAssymetry (Variable *v) {
EnsureUnicity();
list<vector<Element> > lcall ;
list<vector<Element> > lcallres;
list<Guard *>::iterator it;
list<Guard *> &l = this->FindPredOnVar (*v);
if (! l.empty() ) {
Guard * g = CanonizePredTree (this,v);
l = g->FindPredOnVar (*v);
for (it = l.begin();it != l.end() ; it++ )
lcall.push_back( (*it) -> set);
}
lcall.push_back(v->PClass()->Elts());
lcallres = calcSub::uniquePartition (lcall);
// for (it = l.begin();it != l.end() ; it++ )
// (*it)->RewritePredWithPart (lcallres);
// cerr << endl << "Get Assymetry over variable " << *v << " for guard g=" << *this << endl;
// calcSub::print(cerr,lcallres);
return lcallres;
}
示例3: guard_gc
static int
guard_gc (lua_State *L)
{
Guard *guard = lua_touserdata (L, 1);
if (guard->data != NULL)
guard->destroy (guard->data);
return 0;
}
示例4: loadServers
//---------------------------------------------------------------------
// reload the config
size_t Server::loadServers() {
Guard guard;
if (guard.isLoaded()) {
serverInfos.clear();
guard.mapper->import_putty_sessions(serverInfos);
}
return serverInfos.size();
}
示例5:
bool
Routing_Slip_Queue::dispatch_one (Guard & guard)
{
bool ok = false;
Routing_Slip_Ptr routing_slip;
if (this->queue_.dequeue_head (routing_slip) == 0)
{
++this->active_;
guard.release ();
routing_slip->at_front_of_persist_queue ();
guard.acquire ();
}
return ok;
}
示例6: peek_evid_userptr
void ProcessVariable::unsubscribe(Guard &guard)
{
guard.check(__FILE__, __LINE__, mutex);
// See comments in stop(): this->id is already 0, state==INIT.
if (isSubscribed(guard))
{
#ifdef CHECK_EVID
void *user = peek_evid_userptr(ev_id);
LOG_ASSERT(user == this);
#endif
evid _ev_id = ev_id;
ev_id = 0;
GuardRelease release(__FILE__, __LINE__, guard);
{
Guard ctx_guard(__FILE__, __LINE__, ctx);
LOG_ASSERT(ctx.isAttached(ctx_guard));
}
try
{
ca_clear_subscription(_ev_id);
}
catch (std::exception &e)
{
LOG_MSG("ProcessVariable::unsubscribe(%s): %s\n",
getName().c_str(), e.what());
}
catch (...)
{
LOG_MSG("ProcessVariable::unsubscribe(%s): Unknown Exception\n",
getName().c_str());
}
}
}
示例7: release
void ProcessVariable::getValue(Guard &guard)
{
guard.check(__FILE__, __LINE__, mutex);
if (state != CONNECTED)
return; // Can't get
++outstanding_gets;
chid _id = id;
GuardRelease release(__FILE__, __LINE__, guard); // Unlock while in CAC.
{
int status;
try
{
status = ca_array_get_callback(dbr_type, dbr_count,
_id, value_callback, this);
}
catch (std::exception &e)
{
LOG_MSG("ProcessVariable::getValue(%s): %s\n",
getName().c_str(), e.what());
}
catch (...)
{
LOG_MSG("ProcessVariable::getValue(%s): Unknown Exception\n",
getName().c_str());
}
if (status != ECA_NORMAL)
{
LOG_MSG("%s: ca_array_get_callback failed: %s\n",
getName().c_str(), ca_message(status));
return;
}
Guard ctx_guard(__FILE__, __LINE__, ctx);
ctx.requestFlush(ctx_guard);
}
}
示例8: main
int main() {
Player player;
Witch witch;
witch.setName("Lucia");
Guard guard;
guard.setName("Sam");
std::cout << "|Player walks around the town and talks with some npcs" << std::endl;
witch.interact(&player);
guard.interact(&player);
std::cout << "|Player goes on a great adventure!" << std::endl;
std::cout << "|but gets beaten up by some foes..." << std::endl;
player.setHp(player.getHp() - 5);
std::cout << "|Back to the town... Let's talk to the witch" << std::endl;
witch.interact(&player);
}
示例9: addChannel
void GroupInfo::addChannel(Guard &group_guard, ArchiveChannel *channel)
{
group_guard.check(__FILE__, __LINE__, mutex);
// Is Channel already in group?
stdList<ArchiveChannel *>::iterator i;
for (i=channels.begin(); i!=channels.end(); ++i)
if (*i == channel)
return;
channels.push_back(channel);
}
示例10: decConnected
// called by ArchiveChannel
void GroupInfo::decConnected(Guard &group_guard, ArchiveChannel &pv)
{
group_guard.check(__FILE__, __LINE__, mutex);
if (num_connected <= 0)
throw GenericException(__FILE__, __LINE__,
"Group %s connect count runs below 0 "
"on decrement from '%s'",
getName().c_str(), pv.getName().c_str());
--num_connected;
}
示例11: range
/*! \internal
\a n is in the signal index range (see QObjectPrivate::signalIndex()).
*/
void QQmlJavaScriptExpression::GuardCapture::captureProperty(QObject *o, int c, int n)
{
if (watcher->wasDeleted())
return;
Q_ASSERT(expression);
if (n == -1) {
if (!errorString) {
errorString = new QStringList;
QString preamble = QLatin1String("QQmlExpression: Expression ") +
expression->m_vtable->expressionIdentifier(expression) +
QLatin1String(" depends on non-NOTIFYable properties:");
errorString->append(preamble);
}
const QMetaObject *metaObj = o->metaObject();
QMetaProperty metaProp = metaObj->property(c);
QString error = QLatin1String(" ") +
QString::fromUtf8(metaObj->className()) +
QLatin1String("::") +
QString::fromUtf8(metaProp.name());
errorString->append(error);
} else {
// Try and find a matching guard
while (!guards.isEmpty() && !guards.first()->isConnected(o, n))
guards.takeFirst()->Delete();
Guard *g = 0;
if (!guards.isEmpty()) {
g = guards.takeFirst();
g->cancelNotify();
Q_ASSERT(g->isConnected(o, n));
} else {
g = Guard::New(expression, engine);
g->connect(o, n, engine);
}
expression->activeGuards.prepend(g);
}
}
示例12: ACE_ASSERT
template<ACE_SYNCH_DECL> void
Log_Message_Receiver_Impl<ACE_SYNCH_USE>::detach (Log_Message_Receiver_Impl<ACE_SYNCH_USE> *body)
{
ACE_ASSERT (body != 0);
#if defined (ACE_HAS_THREADS)
# if !defined (ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES)
Guard guard (copy_lock_);
if (guard.locked () == 0)
return;
# else
// Use the "body"s print lock as copy lock.
ACE_GUARD (ACE_SYNCH_MUTEX,
guard,
global_copy_lock_);
# endif /* ACE_LACKS_STATIC_DATA_MEMBER_TEMPLATES */
#endif /* ACE_HAS_THREADS */
if (body->count_-- == 0)
delete body;
}
示例13: assert
CURRINT_REPOSITORY_TEMPL_
void RepositoryBase<CURRINT_REPOSITORY_T_>
//
::delete_object (Guard<Obj,wait_m>& obj/*, bool freeMemory*/)
{
assert (obj);
const ObjId objId = fromString<ObjId>
(obj->universal_id());
// (obj.operator->()->universal_id());
delete_object_by_id (objId/*, freeMemory*/);
}
示例14: while
void QQmlJavaScriptExpression::GuardCapture::captureProperty(QQmlNotifier *n)
{
if (expression) {
// Try and find a matching guard
while (!guards.isEmpty() && !guards.first()->isConnected(n))
guards.takeFirst()->Delete();
Guard *g = 0;
if (!guards.isEmpty()) {
g = guards.takeFirst();
g->cancelNotify();
Q_ASSERT(g->isConnected(n));
} else {
g = Guard::New(expression, engine);
g->connect(n);
}
expression->activeGuards.prepend(g);
}
}
示例15: incConnected
// called by ArchiveChannel
void GroupInfo::incConnected(Guard &group_guard, ArchiveChannel &pv)
{
group_guard.check(__FILE__, __LINE__, mutex);
++num_connected;
if (num_connected > channels.size())
throw GenericException(__FILE__, __LINE__,
"Group %s connect count is %zu out of %zu "
"on increment from '%s'",
getName().c_str(),
(size_t)num_connected,
(size_t)channels.size(),
pv.getName().c_str());
}