static network::connection receive(T& cfg, int max_tries = 100)
{
	network::connection receive_con;
	while ((receive_con = network::receive_data(cfg)) == network::null_connection)
	{
		// loop untill data is received
		SDL_Delay(50);
		if (--max_tries <= 0)
		{
			BOOST_WARN_MESSAGE(max_tries > 0,"receiving data took too long. Preventing for ever loop");
			break;
		}
	}
	return receive_con;
}
Exemplo n.º 2
0
LimitedIo::StopReason
LimitedIo::run(int nOpsLimit, time::nanoseconds timeLimit, time::nanoseconds tick)
{
  BOOST_ASSERT(!m_isRunning);

  if (nOpsLimit <= 0) {
    return EXCEED_OPS;
  }

  m_isRunning = true;

  m_reason = NO_WORK;
  m_nOpsRemaining = nOpsLimit;
  if (timeLimit >= 0_ns) {
    m_timeout = getScheduler().schedule(timeLimit, [this] { afterTimeout(); });
  }

  try {
    if (m_fixture == nullptr) {
      getGlobalIoService().run();
    }
    else {
      // timeLimit is enforced by afterTimeout
      m_fixture->advanceClocks(tick, time::nanoseconds::max());
    }
  }
  catch (const StopException&) {
  }
  catch (...) {
    BOOST_WARN_MESSAGE(false, boost::current_exception_diagnostic_information());
    m_reason = EXCEPTION;
    m_lastException = std::current_exception();
  }

  getGlobalIoService().reset();
  m_timeout.cancel();
  m_isRunning = false;

  return m_reason;
}
Exemplo n.º 3
0
void
test_seq_cst(void)
{
	double sum = 0.0;
	
	/* take 10 samples */
	for (size_t n = 0; n < 10; n++) {
		boost::posix_time::time_duration timeout(0, 0, 10);
		
		total_store_order_test<boost::memory_order_relaxed, boost::memory_order_relaxed> test;
		test.run(timeout);
		if (!test.detected_conflict()) {
			BOOST_WARN_MESSAGE(false, "Failed to detect order=seq_cst violation while ith order=relaxed -- intrinsic ordering too strong for this test");
			return;
		}
		
		std::cout << "seq_cst violation with order=relaxed after " << boost::posix_time::to_simple_string(timeout) << "\n";
		
		sum = sum + timeout.total_microseconds();
	}
	
	/* determine maximum likelihood estimate for average time between
	race observations */
	double avg_race_time_mle = (sum / 10);
	
	/* pick 0.995 confidence (7.44 = chi square 0.995 confidence) */
	double avg_race_time_995 = avg_race_time_mle * 2 * 10 / 7.44;
	
	/* 5.298 = 0.995 quantile of exponential distribution */
	boost::posix_time::time_duration timeout = boost::posix_time::microseconds((long)(5.298 * avg_race_time_995));
	
	std::cout << "run seq_cst for " << boost::posix_time::to_simple_string(timeout) << "\n";
	
	total_store_order_test<boost::memory_order_seq_cst, boost::memory_order_relaxed> test;
	test.run(timeout);
	
	BOOST_CHECK_MESSAGE(!test.detected_conflict(), "sequential consistency");
}
Exemplo n.º 4
0
 void meta_warn(const location& location_)
 {
   const test_result result = test_result::build<Pred>(location_);
   BOOST_WARN_MESSAGE(result.success(), result);
 }
Exemplo n.º 5
0
 ComFixture()
 {
     HRESULT hr = ::CoInitialize(NULL);
     BOOST_WARN_MESSAGE(SUCCEEDED(hr), "::CoInitialize failed");
 }