Exemplo n.º 1
0
 Json::Value LG(const std::string &name, const Json::Value &v)
 {
   mutex.lock();
   Json::Value res = val.get(name, v);
   mutex.unlock();
   return res;
 }
Exemplo n.º 2
0
int main()
{
  m.lock();
  boost::thread t(f);
  boost::this_thread::sleep_for(ms(250));
  m.unlock();
  t.join();

  return boost::report_errors();
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
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
}
Exemplo n.º 5
0
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();
}
Exemplo n.º 6
0
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
}
Exemplo n.º 7
0
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;
	}
}
Exemplo n.º 8
0
void screen_draw_end()
{
	if( corner_clip )
	{
		static int radius = 20;
		radius = min(20, min(surface_during_drawing->w,surface_during_drawing->h));

		std::size_t pitch = surface_during_drawing->pitch;
		std::size_t depth = pitch/surface_during_drawing->w;
		uint8_t * data = (uint8_t*)surface_during_drawing->pixels;

		auto func = [&](std::size_t sx,std::size_t sy,int dx,int dy)
		{
			for(std::size_t x=0;x<radius;x++)
			for(std::size_t y=0;y<radius;y++)
			{
				std::size_t nx = sx+x*dx;
				std::size_t ny = sy+y*dy;
				if( x*x + y*y > radius*radius )
				{
					data[ny*pitch + nx*depth + 3] = 0;
					data[ny*pitch + nx*depth + 0] = 0;
					data[ny*pitch + nx*depth + 1] = 0;
					data[ny*pitch + nx*depth + 2] = 0;
				}
			}
		};

		func(radius-1,radius-1,-1,-1);
		func(radius-1,surface_during_drawing->h-radius,-1,1);
		func(surface_during_drawing->w-radius,radius-1,1,-1);
		func(surface_during_drawing->w-radius,surface_during_drawing->h-radius,1,1);
	}

	SDL_UnlockSurface(surface_during_drawing);

	SDL_RenderPresent(renderer);
	lock.unlock();
}
Exemplo n.º 9
0
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();
}
Exemplo n.º 10
0
void ffmpeg_unlock()
{
	lock.unlock();
}