本文整理汇总了C++中boost::mutex::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ mutex::unlock方法的具体用法?C++ mutex::unlock怎么用?C++ mutex::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::mutex
的用法示例。
在下文中一共展示了mutex::unlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hrFrequentThread
////////////////////////////////////////////////////////////////////////////////
// high recall
////////////////////////////////////////////////////////////////////////////////
void hrFrequentThread(
long start,
long stop,
std::vector<Conjunction> const& conjunctions,
std::map<Rule, OrderedCover> const& basicCovers,
OrderedCover const& trueCover,
double const treshold,
std::vector<Conjunction>& result,
boost::mutex& mutex
)
{
std::vector<Conjunction> _result;
_result.reserve(stop-start);
auto start_i = conjunctions.begin();
auto stop_i = conjunctions.begin();
std::advance(start_i, start);
std::advance(stop_i, stop);
long counter = 0;
for (auto i=start_i ; i!=stop_i ; ++i) {
OrderedCover _ordc(conjunctionCover(*i, basicCovers));
if (_ordc.metrics(trueCover).recall() >= treshold) {
_result.push_back(*i);
counter += 1;
}
// try copying intermediate results
if (counter % 256 == 0) {
if (mutex.try_lock()) {
std::copy(_result.begin(), _result.end(),
std::back_inserter(result));
mutex.unlock();
_result.clear();
}
}
}
// copy to master _result vector
mutex.lock();
std::copy(_result.begin(), _result.end(), std::back_inserter(result));
mutex.unlock();
}
示例2: get_images
void get_images(sensor_msgs::Image::ConstPtr& im,
stereo_msgs::DisparityImage::ConstPtr& dm) {
img_lock.lock();
im = last_img;
dm = last_disp;
//Reset pointers to null
/*
last_img.reset();
last_disp.reset();
*/
img_lock.unlock();
}
示例3: packet_collector_thread_unordered_map_preallocated
void packet_collector_thread_unordered_map_preallocated() {
for (int iteration = 0; iteration < number_of_retries; iteration++) {
for (uint32_t i = 0; i < number_of_ips; i++) {
#ifdef enable_mutexex_in_test
data_counter_mutex.lock();
#endif
DataCounterUnordered[i].udp_in_bytes++;
#ifdef enable_mutexex_in_test
data_counter_mutex.unlock();
#endif
}
}
}
示例4: main
int main()
{
m.lock();
boost::thread t(f);
#if defined BOOST_THREAD_USES_CHRONO
boost::this_thread::sleep_for(ms(250));
#else
#endif
m.unlock();
t.join();
return boost::report_errors();
}
示例5: reset
bool Mapper::reset(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res)
{
waitForMapBuildingCompleted();
// note: no need for locking as we do ros::spin(), to update if we go for multi-threading
publishLock.lock();
TOdomToMap = PM::TransformationParameters::Identity(4,4);
publishLock.unlock();
icp.clearMap();
return true;
}
示例6: main
int main()
{
testclass* test = new testclass();
boost::thread thread(&testclass::print,test);
for(int i = 0; i < 10;i++)
{
mut.lock();
std::cout << "Main" << std::endl;
mut.unlock();
}
thread.join();
delete test;
}
示例7: volumeRegion
Scene::Scene(Camera *cam) :
camera(cam), volumeRegion(NULL), surfaceIntegrator(NULL),
volumeIntegrator(NULL), sampler(NULL),
filmOnly(true)
{
for(u_int i = 0; i < cam->film->GetNumBufferGroups(); i++)
lightGroups.push_back( cam->film->GetGroupName(i) );
// Dade - Initialize the base seed with the standard C lib random number generator
scene_rand_mutex.lock();
seedBase = scene_rng();
scene_rand_mutex.unlock();
}
示例8: write_score
void games_t::write_score(char* _pname, score_t _s) {
if(strlen(_pname) <= 0) return;
mtx_all_games.lock();
FILE* fp;
if ((fp = fopen(score_filename,"r+")) == 0) {
fprintf(stderr, "fopen %s error\n", score_filename);
mtx_all_games.unlock();
return;
}
char line[1024];
while(fgets( line, sizeof(line), fp) ) {
score_t pscore;
char spname[128];
if(sscanf(line,"%d %d %d %s",
&pscore.win,
&pscore.lost,
&pscore.abort,
spname) == 4) {
if(strncmp(_pname, spname, 64) == 0) {
char nline[128];
fseek(fp, -strlen(line), SEEK_CUR);
sprintf(nline, "%d %d %d %s\n",
_s.win, _s.lost, _s.abort, spname);
fwrite(nline, sizeof(char), strlen(nline), fp);
fflush(fp);
fclose(fp);
mtx_all_games.unlock();
return;
}
}
}
char nline[128];
sprintf(nline, "%d %d %d %s\n",
_s.win, _s.lost, _s.abort, _pname);
fwrite(nline, sizeof(char), strlen(nline), fp);
fflush(fp);
fclose(fp);
mtx_all_games.unlock();
}
示例9: servoController
void servoController(int destinationAngle,int isFinished,int originArea){
if(isFinished == 1){
servoTurnUp('c');
servoTurnRL(1,1);
}
else{
servoTurnUp('f');
while(1){
if(1 == servoTurnRL(destinationAngle,headingAngle()))
break;
wifiMutex.lock();
if(originArea != -2 && originArea != indoorArea){
servoTurnUp('c');
servoTurnRL(1,1);
wifiMutex.unlock();
break;
}
wifiMutex.unlock();
}
}
}
示例10: endgame
char games_t::endgame(int _gid) {
if(_gid < 0) return FREE_SPACE;
if(_gid >= MAX_GAME) return FREE_SPACE;
mtx_all_games.unlock();
char ret = FREE_SPACE;
if(infos[_gid].player1_pawns == 0) ret = BLACK;
if(infos[_gid].player2_pawns == 0) ret = WHITE;
if(ret == FREE_SPACE) for(int i = 0; i < BOARD_EDGE; i++) {
if(infos[_gid].board[i] == WHITE) {
ret = WHITE;
break;
}
}
if(ret == FREE_SPACE) for(int i = BOARD_SIZE-BOARD_EDGE; i < BOARD_SIZE; i++) {
if(infos[_gid].board[i] == BLACK) {
ret = BLACK;
break;
}
}
mtx_all_games.unlock();
return ret;
}
示例11: move
// apply move and update turn
void games_t::move(int _gid, int _posI, int _posF) {
if(_gid < 0) return;
if(_gid >= MAX_GAME) return;
if(_posI < 0 || _posI >= BOARD_SIZE) return;
if(_posF < 0 || _posF >= BOARD_SIZE) return;
mtx_all_games.lock();
if(infos[_gid].board[_posF] == WHITE) infos[_gid].player1_pawns --;
if(infos[_gid].board[_posF] == BLACK) infos[_gid].player2_pawns --;
infos[_gid].board[_posF] = infos[_gid].board[_posI];
infos[_gid].board[_posI] = FREE_SPACE;
infos[_gid].turn = inv_col(infos[_gid].turn);
mtx_all_games.unlock();
}
示例12: move_up
void move_up(double distance){
actionlib::SimpleActionClient<jaco_msgs::ArmPoseAction> action_client("/jaco/arm_pose",true);
action_client.waitForServer();
jaco_msgs::ArmPoseGoal pose_goal = jaco_msgs::ArmPoseGoal();
arm_mutex.lock();
pose_goal.pose = arm_pose;
pose_goal.pose.header.frame_id = "/jaco_api_origin";
pose_goal.pose.pose.position.z += distance;
arm_mutex.unlock();
action_client.sendGoal(pose_goal);
wait_for_arm_stopped();
}
示例13: ColorPicker
ColorPicker(){
cloud_sub = n.subscribe("/camera/depth_registered/points", 1000,
&ColorPicker::callback, this);
color_sub = n.subscribe("/object_tracker/segmented_cloud", 1000,
&ColorPicker::segmented_callback, this);
pub = n.advertise<geometry_msgs::Point>("/object_tracker/picked_color", 1000);
has_cloud = false;
segmented = false;
has_desired_color = false;
cloud_mutex.unlock();
cloud = PointColorCloud::Ptr( new PointColorCloud());
segmented_cloud = PointColorCloud::Ptr( new PointColorCloud());
}
示例14: TimerHandler
void TimerHandler(
const boost::system::error_code & error,
boost::shared_ptr< boost::asio::deadline_timer > timer
)
{
if( error )
{
global_stream_lock.lock();
std::cout << "[" << boost::this_thread::get_id()
<< "] Error: " << error << std::endl;
global_stream_lock.unlock();
}
else
{
global_stream_lock.lock();
std::cout << "[" << boost::this_thread::get_id()
<< "] TimerHandler " << std::endl;
global_stream_lock.unlock();
timer->expires_from_now( boost::posix_time::seconds( 5 ) );
timer->async_wait( boost::bind( &TimerHandler, _1, timer ) );
}
}
示例15: f
void f()
{
time_point t0 = Clock::now();
BOOST_TEST(!m.try_lock());
BOOST_TEST(!m.try_lock());
BOOST_TEST(!m.try_lock());
while (!m.try_lock())
;
time_point t1 = Clock::now();
m.unlock();
ns d = t1 - t0 - ms(250);
// This test is spurious as it depends on the time the thread system switches the threads
BOOST_TEST(d < ns(50000000)+ms(1000)); // within 50ms
}