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

C++ slock函数代码示例

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

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



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

示例1: runReal

  void runReal() {
    bool debug  = false;
    bool loaded = false;
    cond::time::TimeType ttype = p->timeType();
    auto r = requests->find( p->tag() );
    cond::Session s;
    try{
      s = connectionPool.createSession( connectionString );
      p->init( s ); 
      p->reload();
      if( ttype==cond::runnumber ){
	p->get( runSel, debug );	
	boost::mutex::scoped_lock slock( my_lock );
	r->second++;
      } else if( ttype==cond::lumiid ){
	p->get( lumiSel, debug );
	boost::mutex::scoped_lock slock( my_lock );
	r->second++;
      } else if( ttype==cond::timestamp){
	p->get( tsSel, debug );
	boost::mutex my_lock;
	r->second++;
      } else {
	std::cout <<"WARNING: iov request on tag "<<p->tag()<<" (timeType="<<cond::time::timeTypeName(p->timeType())<<") has been skipped."<<std::endl;
      }
      s.close();
      //-ap:  not thread-safe!  timex.fetchInt(p->getBufferSize()); // keep track of time vs. size
    } catch ( const cond::Exception& e ){
      std::cout <<"ERROR:"<<e.what()<<std::endl;
    }
  }
开发者ID:BetterWang,项目名称:cmssw,代码行数:31,代码来源:conddb_test_gt_perf.cpp


示例2: slock

int32 event_slot_t::wait(slot_vec_t& signalled_vec, uint32 ms_timeout)
{
        signalled_vec.clear();

        smart_lock_t slock(&_cs);

        for(uint16 i=0; i<_slot_cnt; ++i)
        {
                if(_slot[i]) signalled_vec.push_back(i);
        }
        if(!signalled_vec.empty())
        {
                memset(_slot, 0, _slot_cnt);//reset slots
                return signalled_vec.size(); //only wait on demand
        }
	
	slock.unlock();

	if(!_evt.wait(ms_timeout)) //not time-out
        {
		smart_lock_t slock(&_cs);

                for(uint16 i=0; i<_slot_cnt; ++i)
                {
                        if(_slot[i]) signalled_vec.push_back(i);
                }
                memset(_slot, 0, _slot_cnt);//reset slots
		
		return signalled_vec.size();
        }
        return 0; 
}
开发者ID:ferstar,项目名称:fy2009,代码行数:32,代码来源:fy_base.cpp


示例3: slock

void CPlayerMgr::Process()
{
	if(! m_ForDelete.IsEmpty())
	{
		CSingleLock slock(&m_Mutex, true);
		POSITION pos = m_ForDelete.GetStartPosition();
		while(pos)
		{
			CPlayerTaskSocket * sk;
			m_ForDelete.GetNextAssoc(pos, sk, sk);
			TRACE("%08x delete socket\n", sk);
			delete sk;
		}

		m_ForDelete.RemoveAll();
	}

	if(m_TaskLst.IsEmpty())
		Sleep(1000);
	else
	{
		Sleep(80);

		CSingleLock slock(&m_Mutex, true);

		POSITION pos = m_TaskLst.GetStartPosition();

		// VC-linhai[2007-08-06]:warning C4189: “dwNow” : 局部变量已初始化但不引用
		//DWORD dwNow = GetTickCount();
		while(pos)
		{
			CPlayerTask * task=NULL;
			CSKey k;
			m_TaskLst.GetNextAssoc(pos, k, task);
			if(task && task->m_SockList.IsEmpty()==FALSE)
			{
				if(! task->RequestData())
				{
					m_TaskLst.RemoveKey(k);
					pos = m_TaskLst.GetStartPosition();
				}
			}

			if(task && task->m_SockList.IsEmpty() && task->m_bStarted)
			{
				if(task->m_tmEmptyTask==0)
					task->m_tmEmptyTask = time(NULL);
				else if(time(NULL) - task->m_tmEmptyTask > 12)
				{
					m_TaskLst.RemoveKey(k);
					delete task;
				}
			}
			else
			{
				if(task) task->m_tmEmptyTask = 0;
			}
		}
	}
}
开发者ID:LjApps,项目名称:eMule-VeryCD,代码行数:60,代码来源:PlayerMgr.cpp


示例4: exception

 void task_queue::push( task* item )
 {
     if( item == NULL )
         throw exception( "task_queue::push(): Cannot push a null task" );
     
     {
         scoped_lock< mutex > slock( tq_mutex );
         
         if( status == OPEN )
         {
             switch( item -> getPriority() )
             {
             case PRIVAL_HIGH:
                 data[ 0 ].push_back( item );
                 break;
             case PRIVAL_NONE:
                 data[ 1 ].push_back( item );
                 break;
             case PRIVAL_LOW:
                 data[ 2 ].push_back( item );
                 break;
             default:
                 throw exception( "task_queue::push(): Invalid priority level" );
             }
         }
         else
         {
             ff::write( bqt_out, "Warning: task_queue::push(): Queue closed, deleting pushed task\n" );
             delete item;
         }
     }
     
     tq_cond.broadcast();                                                    // Broadcast so all threads can match against mask
 }
开发者ID:JadeMatrix,项目名称:BQTDraw,代码行数:34,代码来源:bqt_taskqueue.cpp


示例5: main

int main()
{
	int tid1;
	
	turnDebugOn();
	
	smutex_init(&mutex);
	
	printf("Códigos retornados:\n");
	
	printf("swait(12): %d\n", swait(12));
	printf("syield(): %d\n", syield());
	printf("slock(&mutex): %d\n", slock(&mutex));
	printf("sunlock(&mutex): %d\n", sunlock(&mutex));
	
	printf("E finalmente inicializando...\n");
	
	printf("tid1 = screate(1, f_thread, NULL);\n");
	tid1 = screate(1, f_thread, NULL);
	printf("tid1 : %d\n", tid1);
	
	swait(tid1);

	return 0;
}
开发者ID:cesarpastorini,项目名称:sthread,代码行数:25,代码来源:init.c


示例6: slock

 std::pair< float, float > canvas_view::getScrollPercent()
 {
     scoped_lock< mutex > slock( element_mutex );
     
     return std::pair< float, float >( ( float )scroll_offset[ 0 ] / ( float )data_dims[ 0 ],
                                       ( float )scroll_offset[ 1 ] / ( float )data_dims[ 1 ] );
 }
开发者ID:JadeMatrix,项目名称:BQTDraw,代码行数:7,代码来源:bqt_gui_canvasview.cpp


示例7: slock

 void text_rsrc::draw()
 {
     scoped_lock< mutex > slock( text_mutex );
     
     if( update_tex )
         updateTexture();
     
     glColor4f( color[ 0 ], color[ 1 ], color[ 2 ], color[ 3 ] );
     {
         glBindTexture( GL_TEXTURE_2D, gl_tex );
         
         glTranslatef( tex_offset[ 0 ], tex_offset[ 1 ], 0.0f );
         
         glBegin( GL_QUADS );
         {
             glTexCoord2f( 0.0f, 0.0f );
             glVertex2f( 0.0f, 0.0f );
             
             glTexCoord2f( 0.0f, 1.0f );
             glVertex2f( 0.0f, dimensions[ 1 ] );
             
             glTexCoord2f( 1.0f, 1.0f );
             glVertex2f( dimensions[ 0 ], dimensions[ 1 ] );
             
             glTexCoord2f( 1.0f, 0.0f );
             glVertex2f( dimensions[ 0 ], 0.0f );
         }
         glEnd();
         
         glTranslatef( tex_offset[ 0 ] * -1.0f, tex_offset[ 1 ] * -1.0f, 0.0f );
         
         glBindTexture( GL_TEXTURE_2D, 0x00 );
     }
     glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
 }
开发者ID:JadeMatrix,项目名称:BQTDraw,代码行数:35,代码来源:bqt_gui_text_rsrc.cpp


示例8: arrestTaskSystem

 void arrestTaskSystem()
 {
     scoped_lock< mutex > slock( arrest_mutex );
     
     arrested = true;
     arrest_continue = true;
 }
开发者ID:JadeMatrix,项目名称:BQTDraw,代码行数:7,代码来源:bqt_taskexec.cpp


示例9: PlayerDataArrived

int PlayerDataArrived(PLAYER_DATA_REQ * req, void * data, int len)
{
	if(req==NULL)
	{
		return 2;
	}
	if(!g_PlayerMgr) return 3;

	CSingleLock slock(&CPlayerMgr::m_Mutex, true);

	DWORD pos = req->pos;
	CSKey key(req->filehash);
	delete req;

	CPlayerTask * pTask = g_PlayerMgr->GetPlayerTask(key);
	if(! pTask)
		return 3;

	if(!pTask->SendData(pos, data, len))
	{
		return 4;
	}



	return 0;
}
开发者ID:LjApps,项目名称:eMule-VeryCD,代码行数:27,代码来源:PlayerMgr.cpp


示例10: getPlan

static Transform::shared_ptr_type getPlan(uint64_t const size, bool const forward)
{
	std::map < uint64_t, std::vector<Transform::shared_ptr_type> > & plans = forward ? forwardPlans : backwardPlans;
	libmaus2::parallel::ScopePosixMutex slock(planlock);

	if ( plans.find(size) == plans.end() )
		plans[size] = std::vector<Transform::shared_ptr_type>(0);

	std::map < uint64_t, std::vector<Transform::shared_ptr_type> >::iterator it = plans.find(size);
	assert ( it != plans.end() );

	std::vector<Transform::shared_ptr_type> & V = it->second;

	if ( ! V.size() )
	{
		// std::cerr << "allocating plan of size " << size << std::endl;
		V.push_back(Transform::shared_ptr_type(new Transform(size,forward)));
	}

	assert ( V.size() );

	Transform::shared_ptr_type T = V.back();
	V.pop_back();

	assert ( T->size == size );
	assert ( T->forward == forward );

	T->reset();

	return T;
}
开发者ID:gt1,项目名称:libmaus2,代码行数:31,代码来源:Convolution_fftw.cpp


示例11: get

			value_type get(uint64_t const i) const
			{
				if ( i >= numentries )
				{
					libmaus2::exception::LibMausException se;
					se.getStream() << "SparseGammaGapFileIndexDecoder::get() out of range: " << i << " >= " << numentries << std::endl;
					se.finish();
					throw se;
				}
			
				libmaus2::parallel::ScopeLock slock(lock);

				// check cache
				if ( cache.find(i) != cache.end() )
					return cache.find(i)->second;
				
				in.clear();
				in.seekg(-2*sizeof(uint64_t)-2*numentries*sizeof(uint64_t) + i*(2*sizeof(uint64_t)), std::ios::end);
				uint64_t const ikey = libmaus2::util::NumberSerialisation::deserialiseNumber(in);
				uint64_t const ibitoff = libmaus2::util::NumberSerialisation::deserialiseNumber(in);
				value_type const v(ikey,ibitoff);
				
				// extend cache
				cache[i] = v;
				
				return v;
			}
开发者ID:jameslz,项目名称:libmaus2,代码行数:27,代码来源:SparseGammaGapFileIndexDecoder.hpp


示例12: slock

void ompl::tools::ParallelPlan::solveMore(base::Planner *planner, std::size_t minSolCount, std::size_t maxSolCount, const base::PlannerTerminationCondition *ptc)
{
    time::point start = time::now();
    if (planner->solve(*ptc))
    {
        double duration = time::seconds(time::now() - start);
        foundSolCountLock_.lock();
        unsigned int nrSol = ++foundSolCount_;
        foundSolCountLock_.unlock();

        if (nrSol >= maxSolCount)
            ptc->terminate();

        msg_.debug("Solution found by %s in %lf seconds", planner->getName().c_str(), duration);

        const std::vector<base::PlannerSolution> &paths = pdef_->getGoal()->getSolutions();

        boost::mutex::scoped_lock slock(phlock_);
        start = time::now();
        unsigned int attempts = 0;
        for (std::size_t i = 0 ; i < paths.size() ; ++i)
            attempts += phybrid_->recordPath(paths[i].path_, false);

        if (phybrid_->pathCount() >= minSolCount)
            phybrid_->computeHybridPath();

        duration = time::seconds(time::now() - start);
        msg_.debug("Spent %f seconds hybridizing %u solution paths (attempted %u connections between paths)", duration, (unsigned int)phybrid_->pathCount(), attempts);
    }
}
开发者ID:megan-starr9,项目名称:UAV_Aiolos,代码行数:30,代码来源:ParallelPlan.cpp


示例13: slock

void ompl::base::CForestStateSampler::getNextSample(State *state)
{
    std::lock_guard<std::mutex> slock(statesLock_);
    space_->copyState(state, statesToSample_.back());
    space_->freeState(statesToSample_.back());
    statesToSample_.pop_back();
}
开发者ID:dbolkensteyn,项目名称:ompl,代码行数:7,代码来源:CForestStateSampler.cpp


示例14: slock

std::map<std::string, double> planning_scene_monitor::CurrentStateMonitor::getCurrentStateValues() const
{
  std::map<std::string, double> m;
  boost::mutex::scoped_lock slock(state_update_lock_);
  kstate_.getStateValues(m);
  return m;
}
开发者ID:mpomarlan,项目名称:moveit_puzzle_demo,代码行数:7,代码来源:current_state_monitor.cpp


示例15: fy_gettid

void aio_provider_t::init_hb_thd()
{
	_hb_tid = fy_gettid();

#ifdef LINUX
	signal(SIGPIPE, SIG_IGN);
#if defined(__ENABLE_EPOLL__)
#else
	if(!aio_provider_t::_s_sigio_is_hooked)
	{
		smart_lock_t slock(&aio_provider_t::_s_cs);
		if(!aio_provider_t::_s_sigio_is_hooked)
		{
			signal(SIGIO, _s_catch_sigio); //lazy hook SIGIO within process scope
			aio_provider_t::_s_sigio_is_hooked = true; 
		}	
	}
	_hb_tid=fy_gettid();
	sigaddset(&_sigset, AIO_RTS_NUM);
	//sigaddset(&_sigset, SIGIO); //it doesn't work on linux 2.6
	sigprocmask(SIG_BLOCK, &_sigset, NULL);
#endif
#elif defined(WIN32)
#endif
}
开发者ID:ferstar,项目名称:fy2009,代码行数:25,代码来源:fy_aio.cpp


示例16: slock

bool planning_scene_monitor::CurrentStateMonitor::haveCompleteState(const ros::Duration &age,
                                                                    std::vector<std::string> &missing_states) const
{
  bool result = true;
  const std::vector<std::string> &dof = robot_model_->getVariableNames();
  ros::Time now = ros::Time::now();
  ros::Time old = now - age;
  boost::mutex::scoped_lock slock(state_update_lock_);
  for (std::size_t i = 0 ; i < dof.size() ; ++i)
  {
    if (isPassiveDOF(dof[i]))
      continue;
    std::map<std::string, ros::Time>::const_iterator it = joint_time_.find(dof[i]);
    if (it == joint_time_.end())
    {
      ROS_DEBUG("Joint variable '%s' has never been updated", dof[i].c_str());
      missing_states.push_back(dof[i]);
      result = false;
    }
    else
      if (it->second < old)
      {
        ROS_DEBUG("Joint variable '%s' was last updated %0.3lf seconds ago (older than the allowed %0.3lf seconds)",
                  dof[i].c_str(), (now - it->second).toSec(), age.toSec());
        missing_states.push_back(dof[i]);
        result = false;
      }
  }
  return result;
}
开发者ID:ehuang3,项目名称:moveit_ros,代码行数:30,代码来源:current_state_monitor.cpp


示例17: isOptimized

 bool isOptimized()
 {
     std::lock_guard<std::mutex> slock(lock_);
     bool result = false;
     if (!solutions_.empty())
         result = solutions_[0].optimized_;
     return result;
 }
开发者ID:dbolkensteyn,项目名称:ompl,代码行数:8,代码来源:ProblemDefinition.cpp


示例18: isApproximate

 bool isApproximate()
 {
     std::lock_guard<std::mutex> slock(lock_);
     bool result = false;
     if (!solutions_.empty())
         result = solutions_[0].approximate_;
     return result;
 }
开发者ID:dbolkensteyn,项目名称:ompl,代码行数:8,代码来源:ProblemDefinition.cpp


示例19: post

			void post()
			{
				ScopeMutexLock slock(mutex);

				sigcnt += 1;
				
				pthread_cond_signal(&cond);
			}
开发者ID:jameslz,项目名称:libmaus2,代码行数:8,代码来源:PosixConditionSemaphore.hpp


示例20: getTopSolution

 PathPtr getTopSolution()
 {
     std::lock_guard<std::mutex> slock(lock_);
     PathPtr copy;
     if (!solutions_.empty())
         copy = solutions_[0].path_;
     return copy;
 }
开发者ID:dbolkensteyn,项目名称:ompl,代码行数:8,代码来源:ProblemDefinition.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ slock_lock函数代码示例发布时间:2022-05-30
下一篇:
C++ slist_add函数代码示例发布时间: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