Exemplo n.º 1
0
void ThreadLocalTester::run() {

    // Wait until finished is true
    while (!isStopping()) {

        Command command = this->command;

        switch (Command(this->command)) {
            case SETDATA:
                data.set(setData);
                // Reset to no command
                this->command = NONE;
                break;
            case GETDATA:
                getData = *data.get();
                // Reset to no command
                this->command = NONE;
                break;
            case NONE:
                // Sleep for 30 ms
                std::this_thread::sleep_for(std::chrono::milliseconds(30));
                break;
        }
    }
}
Exemplo n.º 2
0
//static
CoroutineManager& CoroutineManager::getInstance()
{
	CoroutineManager *pInstance = coroutineManagerInstance;
	if(!pInstance) {
		pInstance = new CoroutineManager();
		coroutineManagerInstance.set(pInstance);
	}
	return *pInstance;
}
Exemplo n.º 3
0
// Tests that the threadlocal data is unique between threads
TEST(TestThreadLocal, MainThread) {

    // Initialize ThreadLocal storage
    ThreadLocal<int> data;

    // Set value to 123
    data.set(123);

    // Confirm that it equals
    ASSERT_EQ(*data.get(), 123);
}
Exemplo n.º 4
0
  inline void operator()()
  {
    staticThinggy = new Thinggy;
    staticThreadLocal.set(staticThinggy);
    waiting = true;
    gate.Set();
    waiter.Wait();
    waiting = false;

    threadLocalHadValue = staticThreadLocal.get() != NULL;
    gate.Set();
  }
Exemplo n.º 5
0
void test_threadlocalstroage()
{
    g_tls->set(10);
    g_tls->print();

    Thread t1(std::bind(testTLS, 23));
    t1.join();

    Thread t2(std::bind(testTLS, 100));
    t2.join();

    g_tls->print();
}
	void increment() { value.set(value.get() + 1); }
	ThreadLocalVariables() : canceled(false){
		value.set(0);
	}