• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sentry函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: __acquire_category

static void*
__acquire_category(const char* &name, char *buf, _Locale_name_hint* hint,
                   loc_extract_name_func_t extract_name,
                   loc_create_func_t create_obj, loc_default_name_func_t default_name,
                   Category_Map ** M, int *__err_code) {
  typedef Category_Map::iterator Category_iterator;
  pair<Category_iterator, bool> result;

  *__err_code = _STLP_LOC_UNDEFINED;

  // Find what name to look for. Be careful if user requests the default.
  if (name[0] == 0) {
    name = default_name(buf);
    if (name == 0 || name[0] == 0)
      name = "C";
  }
  else {
    const char* cname = extract_name(name, buf, hint, __err_code);
    if (cname == 0) {
      return 0;
    }
    name = cname;
  }

  Category_Map::value_type __e(name, pair<void*,size_t>((void*)0,size_t(0)));

  _STLP_auto_lock sentry(category_hash_mutex());

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

  // Look for an existing entry with that name.
  result = (*M)->insert_noresize(__e);

  if (result.second) {
    // There was no entry in the map already.  Create the category.
    (*result.first).second.first = create_obj(name, hint, __err_code);
    if (!(*result.first).second.first) {
      (*M)->erase(result.first);
#if defined (_STLP_LEAKS_PEDANTIC)
      if ((*M)->empty()) {
        delete *M;
        *M = 0;
      }
#endif
      return 0;
    }
  }

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

  return (*result.first).second.first;
}
开发者ID:dannf,项目名称:ti-cgt-c6x,代码行数:54,代码来源:locale_catalog.cpp


示例17: sentry

std::ostream &operator<<(std::ostream &str, const mean_result<T> &self)
{
    internal::check_valid(self);
    internal::format_sentry sentry(str);
    verbosity verb = internal::get_format(str, PRINT_TERSE);

    if (verb == PRINT_VERBOSE)
        str << "<X> = ";
    str << self.mean();
    return str;
}
开发者ID:ALPSCore,项目名称:ALPSCore,代码行数:11,代码来源:mean.cpp


示例18: sentry

	// GTK CALLBACKS
	void TexturePreviewCombo::_onExpose (GtkWidget* widget, GdkEventExpose* ev, TexturePreviewCombo* self)
	{
		// Grab the GLWidget with sentry
		gtkutil::GLWidgetSentry sentry(widget);

		// Initialise viewport
		glClearColor(0.3, 0.3, 0.3, 0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glDisable( GL_DEPTH_TEST);
		glEnable( GL_TEXTURE_2D);

		// If no texture is loaded, leave window blank
		if (self->_texName.empty())
			return;

		glMatrixMode( GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, 1, 0, 1, -1, 1);

		// Get a reference to the selected shader
		IShader* shader = GlobalShaderSystem().getShaderForName(self->_texName);

		// Bind the texture from the shader
		GLTexture* tex = shader->getTexture();
		glBindTexture(GL_TEXTURE_2D, tex->texture_number);

		// Calculate the correct aspect ratio for preview
		float aspect = float(tex->width) / float(tex->height);
		float hfWidth, hfHeight;
		if (aspect > 1.0) {
			hfWidth = 0.5;
			hfHeight = 0.5 / aspect;
		} else {
			hfHeight = 0.5;
			hfWidth = 0.5 * aspect;
		}

		// Draw a polygon
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glColor3f(1, 1, 1);
		glBegin( GL_QUADS);
		glTexCoord2i(0, 1);
		glVertex2f(0.5 - hfWidth, 0.5 - hfHeight);
		glTexCoord2i(1, 1);
		glVertex2f(0.5 + hfWidth, 0.5 - hfHeight);
		glTexCoord2i(1, 0);
		glVertex2f(0.5 + hfWidth, 0.5 + hfHeight);
		glTexCoord2i(0, 0);
		glVertex2f(0.5 - hfWidth, 0.5 + hfHeight);
		glEnd();

		shader->DecRef();
	}
开发者ID:AresAndy,项目名称:ufoai,代码行数:54,代码来源:TexturePreviewCombo.cpp


示例19: _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.
static size_t _Stl_loc_get_index(locale::id& id) {
  if (id._M_index == 0) {
#if defined (_STLP_ATOMIC_INCREMENT)
    id._M_index = _STLP_ATOMIC_INCREMENT(&(locale::id::_S_max));
#else
    static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER;
    _STLP_auto_lock sentry(_Index_lock);
    size_t new_index = locale::id::_S_max++;
    id._M_index = new_index;
#endif
  }
  return id._M_index;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:16,代码来源:locale.cpp


示例20: _Stl_loc_get_index

// Takes a reference to a locale::id, assign a numeric index if not already
// affected and returns it. The returned index is always positive.
static const locale::id& _Stl_loc_get_index(locale::id& id) {
  if (id._M_index == 0) {
#if defined (_STLP_ATOMIC_INCREMENT) && !defined (_STLP_WIN95_LIKE)
    static _STLP_VOLATILE __stl_atomic_t _S_index = __STATIC_CAST(__stl_atomic_t, locale::id::_S_max);
    id._M_index = _STLP_ATOMIC_INCREMENT(&_S_index);
#else
    static _STLP_STATIC_MUTEX _Index_lock _STLP_MUTEX_INITIALIZER;
    _STLP_auto_lock sentry(_Index_lock);
    size_t new_index = locale::id::_S_max++;
    id._M_index = new_index;
#endif
  }
  return id;
}
开发者ID:ChunHungLiu,项目名称:stlport,代码行数:16,代码来源:locale.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sep函数代码示例发布时间:2022-05-30
下一篇:
C++ sentinel函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap