Beispiel #1
0
int RenderContext::render(void) {

  tm.Start();
  glm::uvec3 counters = glm::uvec3(0);
  ac.reset();
  glfwGetCursorPos(window, &pos_x, &pos_y);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  mb.render(iter, aspect_ratio, cx, cy, cur_scale);
  text.print(hud, 10, 50, screen_width, screen_height);

  counters = ac.read();

  tm.Stop();
  float time = tm.Report();
  glfwSwapBuffers(window);
  glfwPollEvents();

  float mod = glm::clamp(16000.0f / time, .1f, 2.0f);
  iter = glm::clamp(int(iter * mod), 10, 50000) ;
  // iter = 100;
  snprintf(hud, sizeof(hud), "%5.2fms, %5E, %5i,\n%5.3E, %6f, %6f \n",
           time/1000, double(counters[0]), iter, cur_scale, cx, cy);
  // printf("%s\n", hud);

  return 0;
}
void DFUTransportUSB::init()
{
	if(init_counter.inc() == 1)
	{
		map = new CMapX<CStringX, const TCHAR *, CStringX, const TCHAR *>;
		lockMap = new CriticalSection;
	}
}
void DFUFileInfoCache::init()
{
	if(init_counter.inc() == 1)
	{
		map = new CMapX<CStringX, const TCHAR *, DFUFileInfoCache::Cache, DFUFileInfoCache::Cache &>;
		lockMap = new CriticalSection;
	}
	DFUFileCache::init();
}
void DFUTransportUSB::deinit()
{
	if(init_counter.dec() == 0)
	{
		delete map;
		map = NULL;
		delete lockMap;
		lockMap = NULL;
	}
}
void DFUFileInfoCache::deinit()
{
	DFUFileCache::deinit();
	if(init_counter.dec() == 0)
	{
		delete map;
		map = NULL;
		delete lockMap;
		lockMap = NULL;
	}
}
Beispiel #6
0
const string& UniqueID()
{
   static AtomicCounter cnt; // a GLOBAL counter
   

   NTL_THREAD_LOCAL static string ID;
   NTL_THREAD_LOCAL static bool initialized = false;
   NTL_THREAD_LOCAL static unsigned long local_cnt = cnt.inc();
   NTL_THREAD_LOCAL static unsigned long local_time = time(0);
   NTL_THREAD_LOCAL static unsigned long local_clock = clock();

   if (!initialized) {
      stringstream ss;
      ss << local_cnt << "-" << local_time << "-" 
         << local_clock << "-" << GetPID()  << "-" << CurrentThreadID();  
      ID = ss.str();
      initialized = true;
   }

   return ID;
}
Beispiel #7
0
void CoreTest::testAtomicCounter()
{
	AtomicCounter ac;
	
	assert (ac.value() == 0);
	assert (ac++ == 0);
	assert (ac-- == 1);
	assert (++ac == 1);
	assert (--ac == 0);
	
	ac = 2;
	assert (ac.value() == 2);
	
	ac = 0;
	assert (ac.value() == 0);
	
	AtomicCounter ac2(2);
	assert (ac2.value() == 2);
	
	ACTRunnable act(ac);
	Thread t1;
	Thread t2;
	Thread t3;
	Thread t4;
	Thread t5;
	
	t1.start(act);
	t2.start(act);
	t3.start(act);
	t4.start(act);
	t5.start(act);
	
	t1.join();
	t2.join();
	t3.join();
	t4.join();
	t5.join();
	
	assert (ac.value() == 0);
}
const string& UniqueID()
{
   static AtomicCounter cnt; // a GLOBAL counter
   

   NTL_TLS_LOCAL(string, ID);

   NTL_TLS_LOCAL_INIT(bool, initialized, (false));
   NTL_TLS_LOCAL_INIT(unsigned long, local_cnt, (cnt.inc()));
   NTL_TLS_LOCAL_INIT(unsigned long, local_time, (time(0)));
   NTL_TLS_LOCAL_INIT(unsigned long, local_clock, (clock()));

   if (!initialized) {
      stringstream ss;
      ss << local_cnt << "-" << local_time << "-" 
         << local_clock << "-" << GetPID()  << "-" << CurrentThreadID();  
      ID = ss.str();
      initialized = true;
   }

   return ID;
}
Beispiel #9
0
AtomicCounter::AtomicCounter(const AtomicCounter& counter):
    _counter(counter.value())
{
}
AtomicCounter::AtomicCounter(const AtomicCounter& counter)
{
	_counter.value = counter.value();
}
Beispiel #11
0
 void reset() {
   success = 0;
   failure = 0;
   cnt.reset();
 }