本文整理汇总了C++中ThreadLocal::set方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadLocal::set方法的具体用法?C++ ThreadLocal::set怎么用?C++ ThreadLocal::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadLocal
的用法示例。
在下文中一共展示了ThreadLocal::set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
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;
}
}
}
示例2: CoroutineManager
//static
CoroutineManager& CoroutineManager::getInstance()
{
CoroutineManager *pInstance = coroutineManagerInstance;
if(!pInstance) {
pInstance = new CoroutineManager();
coroutineManagerInstance.set(pInstance);
}
return *pInstance;
}
示例3:
// 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);
}
示例4: operator
inline void operator()()
{
staticThinggy = new Thinggy;
staticThreadLocal.set(staticThinggy);
waiting = true;
gate.Set();
waiter.Wait();
waiting = false;
threadLocalHadValue = staticThreadLocal.get() != NULL;
gate.Set();
}
示例5: test_threadlocalstroage
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();
}
示例6: increment
void increment() { value.set(value.get() + 1); }
示例7: canceled
ThreadLocalVariables() : canceled(false){
value.set(0);
}