当前位置: 首页>>代码示例>>C++>>正文


C++ Guard类代码示例

本文整理汇总了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;
  }
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:27,代码来源:guardedMemory.cpp

示例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;

}
开发者ID:cosyverif,项目名称:deb-libsnow,代码行数:27,代码来源:Guard.cpp

示例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;
}
开发者ID:heirecka,项目名称:lgi,代码行数:8,代码来源:core.c

示例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();
}
开发者ID:BackupTheBerlios,项目名称:sftp4tc-svn,代码行数:10,代码来源:server.cpp

示例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;
 }
开发者ID:binary42,项目名称:OCI,代码行数:14,代码来源:Routing_Slip_Queue.cpp

示例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());
        }    
    }    
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:33,代码来源:ProcessVariable.cpp

示例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);
    }    
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:35,代码来源:ProcessVariable.cpp

示例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);
}
开发者ID:Luaing,项目名称:luabridge-classes,代码行数:17,代码来源:main.cpp

示例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);
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:10,代码来源:GroupInfo.cpp

示例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;
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:11,代码来源:GroupInfo.cpp

示例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);
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:46,代码来源:qqmljavascriptexpression.cpp

示例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;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:20,代码来源:Log_Message_Receiver.cpp

示例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*/);
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例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);
    }
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:21,代码来源:qqmljavascriptexpression.cpp

示例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());    
}
开发者ID:EPICSTools,项目名称:ChannelArchiver,代码行数:14,代码来源:GroupInfo.cpp


注:本文中的Guard类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。