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


C++ sentry函数代码示例

本文整理汇总了C++中sentry函数的典型用法代码示例。如果您正苦于以下问题:C++ sentry函数的具体用法?C++ sentry怎么用?C++ sentry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sentry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: __release_category

static void
__release_category(void* cat,
                   loc_destroy_func_t destroy_fun,
                   loc_name_func_t get_name,
                   Category_Map** M)
{
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
_STLP_auto_lock sentry(get_locale_catalog_category_hash_lock());
# else
_STLP_auto_lock sentry(__category_hash_lock);
# endif

    if (cat && (*M)) {
        // Find the name of the category object.
        char buf[_Locale_MAX_SIMPLE_NAME + 1];
        char* name = get_name(cat, buf);

        if (name != 0) {
            Category_Map::iterator it = (*M)->find(name);
            if (it != (*M)->end()) {
                // Decrement the ref count.  If it goes to zero, delete this category
                // from the map.
                if (--((*it).second.second) == 0) {
                    void* cat1 = (*it).second.first;
                    destroy_fun(cat1);
                    (*M)->erase(it);
                    delete (*M);
                    *M = NULL;
                }
            }
        }
    }
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:33,代码来源:locale_catalog.cpp

示例2: dprintf

int CgroupLimits::set_cpu_shares(uint64_t shares)
{
	if (!m_cgroup.isValid() || !CgroupManager::getInstance().isMounted(CgroupManager::CPU_CONTROLLER)) {
		dprintf(D_ALWAYS, "Unable to set CPU shares because cgroup is invalid.\n");
		return 1;
	}

	int err;
	struct cgroup *cpucg = &m_cgroup.getCgroup();
	struct cgroup_controller *cpu_controller;

	if ((cpu_controller = cgroup_get_controller(cpucg, CPU_CONTROLLER_STR)) == NULL) {
		dprintf(D_ALWAYS,
			"Unable to add cgroup CPU controller for %s.\n",
			m_cgroup_string.c_str());
			return 1;
	} else if ((err = cgroup_set_value_uint64(cpu_controller, "cpu.shares", shares))) {
		dprintf(D_ALWAYS,
			"Unable to set CPU shares for %s: %u %s\n",
			m_cgroup_string.c_str(), err, cgroup_strerror(err));
			return 1;
	} else {
		TemporaryPrivSentry sentry(PRIV_ROOT);
		if ((err = cgroup_modify_cgroup(cpucg))) {
			dprintf(D_ALWAYS,
				"Unable to commit CPU shares for %s"
				": %u %s\n",
				m_cgroup_string.c_str(), err, cgroup_strerror(err));
			return 1;
		}
	}
	return 0;
}
开发者ID:Clusterforge,项目名称:htcondor,代码行数:33,代码来源:cgroup_limits.cpp

示例3: sentry

std::ostream &
operator<<(std::ostream & out, const Configuration & configuration)
{
    std::ostream::sentry sentry(out);

    if (sentry)
    {
        out << "mode: " << configuration.mode << "\n";
        out << "endpoint: " << configuration.endpoint << "\n";
        out << "send_bandwidth: "
            << configuration.send_bandwidth << "/s\n";
        out << "receive_bandwidth: "
            << configuration.receive_bandwidth << "/s\n";
        out << "bandwidth_sampling_frequency: "
            << configuration.bandwidth_sampling_frequency << "Hz\n";
        out << "verify: " << configuration.verify << "\n";
        if (configuration.windows != 0)
            out << "windows: " << configuration.windows << "\n";
        else
            out << "windows: default system value\n";
        out << "size: " << configuration.size << "\n";
        if (configuration.duration_margin.is_special())
            out << "duration_margin: default\n";
        else
            out << "duration_margin: "
                << configuration.duration_margin << "\n";
        out << "shutdown_policy: "
            << configuration.shutdown_policy << "\n";
        out << std::flush;
    }

    return out;
}
开发者ID:enyx-opensource,项目名称:net-tools,代码行数:33,代码来源:Configuration.cpp

示例4: GetTickCount

void TimerWheel::OnEvent()
{
	DWORD nowTick = GetTickCount();

	std::vector<Entity> expiredTimes;
	expiredTimes.clear();

	Entity sentry(nowTick, NULL);
	TimerList::iterator end = _allTimers.lower_bound(sentry);
	assert(end == _allTimers.end() || nowTick < end->first);
	std::copy(_allTimers.begin(), end, back_inserter(expiredTimes));
	_allTimers.erase(_allTimers.begin(), end);

	for (std::vector<Entity>::iterator iter = expiredTimes.begin()
		; iter != expiredTimes.end()
		; ++iter)
	{
		iter->second->_timer->OnTimer(nowTick);
		if (iter->second->_interval != 0)
		{
			iter->second->_when = nowTick + iter->second->_interval;
			_allTimers.insert(Entity(iter->second->_when, iter->second));
		}
		else
		{
			delete iter->second;
		}
	}
}
开发者ID:SpiritDyn123,项目名称:CYGameServer,代码行数:29,代码来源:TimerWheel.cpp

示例5: load

        inline bool load(text_wrapper<T> & wrapper)
        {
            BOOST_STATIC_ASSERT( (boost::is_arithmetic<T>::value) );

            T & t = wrapper.data();
            try
            {
                rollback_sentry sentry(this);
                std::istreambuf_iterator<char> input_first(&m_sb);
                std::istreambuf_iterator<char> input_last;
                std::string buffer;
                std::streamsize ls = 0;
                bool bOk = false;
                while (input_first != input_last)
                {
                    ++ls;
                    char ch = *input_first++;
                    if (ch == ' ')
                    {
                        bOk = true;
                        break;
                    }

                    buffer += ch;
                }
                m_acc += ls;
                t = boost::lexical_cast<T>(buffer);
                return sentry.wrap(bOk);
            }
            catch(std::exception &)
            {
                return false;
            }
        }
开发者ID:coldzhang,项目名称:Bex,代码行数:34,代码来源:text_iarchive.hpp

示例6: sentry

    void ClientStub::instantiateTransport()
    {
        CurrentClientStubSentry sentry(*this);
        if (!mTransport.get())
        {
            RCF_VERIFY(mEndpoint.get(), Exception(_RcfError_NoEndpoint()));
            mTransport.reset( mEndpoint->createClientTransport().release() );
            RCF_VERIFY(mTransport.get(), Exception(_RcfError_TransportCreation()));
        }

        if (    mAsync 
            &&  !mTransport->isAssociatedWithIoService())
        {
            RcfServer * preferred = getAsyncDispatcher();
            AsioIoService * pIoService = NULL;

            if (preferred)
            {
                ServerTransport & transport = preferred->getServerTransport();
                AsioServerTransport & asioTransport = dynamic_cast<AsioServerTransport &>(transport);
                pIoService = & asioTransport.getIoService();
            }
            else
            {
                pIoService = & getAmiThreadPool().getIoService();
            }

            mTransport->associateWithIoService(*pIoService);
        }
    }
开发者ID:tsingcoo,项目名称:study,代码行数:30,代码来源:ClientStub.cpp

示例7: __release_category

static void 
__release_category(void* cat,
                 loc_destroy_func_t destroy_fun,
                 loc_name_func_t get_name,
                 Category_Map* M)
{
  _STL_auto_lock sentry(__category_hash_lock);

  if (cat && M) {
    // Find the name of the category object.
    char buf[_Locale_MAX_SIMPLE_NAME + 1];
    char* name = get_name(cat, buf);

    if (name != 0) {
      Category_Map::iterator it = M->find(name);
      if (it != M->end()) {
        // Decrement the ref count.  If it goes to zero, delete this category
        // from the map.
        if (--((*it).second.second) == 0) {
          void* cat1 = (*it).second.first;
          destroy_fun(cat1);
          M->erase(it);
        }
      }
    }
  }
}
开发者ID:jiayuehua,项目名称:STLport,代码行数:27,代码来源:locale_catalog.cpp

示例8: __release_category

static void 
__release_category(void* cat,
                   loc_destroy_func_t destroy_fun,
                   loc_name_func_t get_name,
                   Category_Map** M) {
  Category_Map *pM = *M;

  if (cat && pM) {
    // Find the name of the category object.
    char buf[_Locale_MAX_SIMPLE_NAME + 1];
    char* name = get_name(cat, buf);

    if (name != 0) {
      _STLP_auto_lock sentry(__category_hash_lock);
      Category_Map::iterator it = pM->find(name);
      if (it != pM->end()) {
        // Decrement the ref count.  If it goes to zero, delete this category
        // from the map.
        if (--((*it).second.second) == 0) {
          void* cat1 = (*it).second.first;
          destroy_fun(cat1);
          pM->erase(it);
#ifdef _STLP_LEAKS_PEDANTIC
          if (pM->empty()) {
            delete pM;
            *M = 0;
          }
#endif /* _STLP_LEAKS_PEDANTIC */
        }
      }
    }
  }
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:33,代码来源:locale_catalog.cpp

示例9: dprintf

//
// JobExit() is called after file transfer.
//
bool DockerProc::JobExit() {
	dprintf( D_ALWAYS, "DockerProc::JobExit()\n" );

	{
	TemporaryPrivSentry sentry(PRIV_ROOT);
	ClassAd dockerAd;
	CondorError error;
	int rv = DockerAPI::inspect( containerName, & dockerAd, error );
	if( rv < 0 ) {
		dprintf( D_ALWAYS | D_FAILURE, "Failed to inspect (for removal) container '%s'.\n", containerName.c_str() );
		return VanillaProc::JobExit();
	}

	bool running;
	if( ! dockerAd.LookupBool( "Running", running ) ) {
		dprintf( D_ALWAYS | D_FAILURE, "Inspection of container '%s' failed to reveal its running state.\n", containerName.c_str() );
		return VanillaProc::JobExit();
	}
	if( running ) {
		dprintf( D_ALWAYS | D_FAILURE, "Inspection reveals that container '%s' is still running.\n", containerName.c_str() );
		return VanillaProc::JobExit();
	}

	rv = DockerAPI::rm( containerName, error );
	if( rv < 0 ) {
		dprintf( D_ALWAYS | D_FAILURE, "Failed to remove container '%s'.\n", containerName.c_str() );
	}
	}

	return VanillaProc::JobExit();
}
开发者ID:blueskyll,项目名称:condor,代码行数:34,代码来源:docker_proc.cpp

示例10: readHexByte

static uint8_t readHexByte(std::istream & s)
{
    std::istream::sentry sentry(s, true);
    if (sentry)
    {
        char c1 = 0, c2 = 0;
        s.get(c1);
        s.get(c2);

        if (s.fail())
        {
            if (s.eof())
            {
                throw std::runtime_error("Unexpected end of line.");
            }
            else
            {
                throw std::runtime_error("Failed to read hex digit.");
            }
        }

        int v1 = hexDigitValue(c1);
        int v2 = hexDigitValue(c2);

        if (v1 < 0 || v2 < 0)
        {
            throw std::runtime_error("Invalid hex digit.");
        }

        return v1 * 16 + v2;
    }
    return 0;
}
开发者ID:bhunting,项目名称:p-load,代码行数:33,代码来源:firmware_archive.cpp

示例11: m_cgroup_string

CgroupLimits::CgroupLimits(std::string &cgroup) : m_cgroup_string(cgroup)
{
	TemporaryPrivSentry sentry(PRIV_ROOT);
	CgroupManager::getInstance().create(m_cgroup_string, m_cgroup,
		CgroupManager::MEMORY_CONTROLLER | CgroupManager::CPU_CONTROLLER | CgroupManager::BLOCK_CONTROLLER,
		CgroupManager::NO_CONTROLLERS,
		false, false);
}
开发者ID:Clusterforge,项目名称:htcondor,代码行数:8,代码来源:cgroup_limits.cpp

示例12: _Stl_loc_get_index

// Takes a reference to a locale::id, and returns its numeric index.
// If no numeric index has yet been assigned, assigns one.  The return
// value is always positive.
size_t _Stl_loc_get_index(locale::id& id)
{
  if (id._M_index == 0) {
    _STL_auto_lock sentry(_Index_lock);
    size_t new_index = locale::id::_S_max++;
    id._M_index = new_index;
  }
  return id._M_index;
}
开发者ID:jiayuehua,项目名称:STLport,代码行数:12,代码来源:locale_impl.cpp

示例13: sentry

void CCheckTextControlDlg::OnCheckRichTextControl() {
	CRichEditCtrl *richEditCtrl = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1);
	CSentrySpellDlg sentry(this);
	SSCE_S16 rv = sentry.Check(richEditCtrl);
	if (rv < 0) {
		CString msg;
		msg.Format(_T("Check returned %hd"), rv);
	}
}
开发者ID:jimmccurdy,项目名称:ArchiveGit,代码行数:9,代码来源:CheckTextControlDlg.cpp

示例14: __acquire_category

static void*
__acquire_category(const char* name, loc_create_func_t create_obj,
                   loc_default_name_func_t default_obj, Category_Map ** M)
{
    typedef Category_Map::iterator Category_iterator;
    pair<Category_iterator, bool> result;
#if defined(__LIBSTD_CPP_SYMBIAN32_WSD__) || defined(_STLP_LIBSTD_CPP_NO_STATIC_VAR_)
    _STLP_auto_lock sentry(get_locale_catalog_category_hash_lock());
# else
    _STLP_auto_lock sentry(__category_hash_lock);
# endif

    typedef const char* key_type;


    if (!*M)
        *M = new Category_Map();

#if defined(__SC__)		//*TY 06/01/2000 - added workaround for SCpp
if(!*M) delete *M;	//*TY 06/01/2000 - it forgets to generate dtor for Category_Map class. This fake code forces to generate one.
#endif					//*TY 06/01/2000 - 

    // Find what name to look for.  Be careful if user requests the default.
    char buf[_Locale_MAX_SIMPLE_NAME];
    if (name == 0 || name[0] == 0)
        name = default_obj(buf);
    if (name == 0 || name[0] == 0)
        name = "C";

    pair<const key_type, pair<void*,size_t> > __e(name, pair<void*,size_t>((void*)0,size_t(0)));

    // Look for an existing entry with that name.

    result = (*M)->insert_noresize(__e);

    // There was no entry in the map already.  Create the category.
    if (result.second)
        (*result.first).second.first = create_obj(name);

    // Increment the reference count.
    ++((*result.first).second.second);

    return (*result.first).second.first;
}
开发者ID:kuailexs,项目名称:symbiandump-os2,代码行数:44,代码来源:locale_catalog.cpp

示例15: sentry

Starter*
StarterMgr::makeStarter( const char* path )
{
	Starter* new_starter;
	FILE* fp;
	char *args[] = { const_cast<char*>(path),
					 const_cast<char*>("-classad"),
					 NULL };
	char buf[1024];

		// first, try to execute the given path with a "-classad"
		// option, and grab the output as a ClassAd
		// note we run the starter here as root if possible,
		// since that is how the starter will be invoked for real,
		// and the real uid of the starter may influence the
		// list of capabilities the "-classad" option returns.
	{
		TemporaryPrivSentry sentry(PRIV_ROOT);
		fp = my_popenv( args, "r", FALSE );
	}

	if( ! fp ) {
		dprintf( D_ALWAYS, "Failed to execute %s, ignoring\n", path );
		return NULL;
	}
	ClassAd* ad = new ClassAd;
	bool read_something = false;
	while( fgets(buf, 1024, fp) ) {
		read_something = true;
		if( ! ad->Insert(buf) ) {
			dprintf( D_ALWAYS, "Failed to insert \"%s\" into ClassAd, "
					 "ignoring invalid starter\n", buf );
			delete( ad );
			pclose( fp );
			return NULL;
		}
	}
	my_pclose( fp );
	if( ! read_something ) {
		dprintf( D_ALWAYS, 
				 "\"%s -classad\" did not produce any output, ignoring\n", 
				 path ); 
		delete( ad );
		return NULL;
	}

	new_starter = new Starter();
	new_starter->setAd( ad );
	new_starter->setPath( path );
	int is_dc = 0;
	ad->LookupBool( ATTR_IS_DAEMON_CORE, is_dc );
	new_starter->setIsDC( (bool)is_dc );

	return new_starter;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:55,代码来源:starter_mgr.cpp


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