void f() { time_point t0 = Clock::now(); m.lock(); time_point t1 = Clock::now(); m.lock(); m.unlock(); 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(2500000)+ms(1000)); // within 2.5ms }
Json::Value LG(const std::string &name, const Json::Value &v) { mutex.lock(); Json::Value res = val.get(name, v); mutex.unlock(); return res; }
int main() { m.lock(); boost::thread t(f); boost::this_thread::sleep_for(ms(250)); m.unlock(); t.join(); return boost::report_errors(); }
void f() { #if defined BOOST_THREAD_USES_CHRONO t0 = Clock::now(); m.lock(); t1 = Clock::now(); m.lock(); m.unlock(); m.unlock(); #else //time_point t0 = Clock::now(); m.lock(); //time_point t1 = Clock::now(); m.lock(); m.unlock(); m.unlock(); //ns d = t1 - t0 - ms(250); //BOOST_TEST(d < max_diff); #endif }
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(); }
void f() { #if defined BOOST_THREAD_USES_CHRONO time_point t0 = Clock::now(); m.lock(); time_point t1 = Clock::now(); m.lock(); m.unlock(); 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(2500000)+ms(1000)); // within 2.5ms #else //time_point t0 = Clock::now(); m.lock(); //time_point t1 = Clock::now(); m.lock(); m.unlock(); 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(2500000)+ms(1000)); // within 2.5ms #endif }
boost::tuple<uint8_t*,int,int,int> screen_draw_begin() { boost::tuple<uint8_t*,int,int,int> ret; lock.lock(); surface_during_drawing = SDL_GetWindowSurface(window); if( surface_during_drawing ) { SDL_LockSurface(surface_during_drawing); ret.get<0>() = (uint8_t*)surface_during_drawing->pixels; ret.get<1>() = surface_during_drawing->pitch; ret.get<2>() = surface_during_drawing->w; ret.get<3>() = surface_during_drawing->h; return ret; } else { lock.unlock(); return ret; } }
int main() { m.lock(); boost::thread t(f); #if defined BOOST_THREAD_USES_CHRONO time_point t2 = Clock::now(); boost::this_thread::sleep_for(ms(250)); time_point t3 = Clock::now(); #else #endif m.unlock(); t.join(); #if defined BOOST_THREAD_USES_CHRONO ns sleep_time = t3 - t2; ns d_ns = t1 - t0 - sleep_time; ms d_ms = boost::chrono::duration_cast<boost::chrono::milliseconds>(d_ns); // BOOST_TEST_GE(d_ms.count(), 0); BOOST_THREAD_TEST_IT(d_ms, max_diff); BOOST_THREAD_TEST_IT(d_ns, ns(max_diff)); #endif return boost::report_errors(); }
void ffmpeg_lock() { lock.lock(); }