当前位置: 首页>>代码示例>>C++>>正文


C++ ThreadLocal::get方法代码示例

本文整理汇总了C++中ThreadLocal::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadLocal::get方法的具体用法?C++ ThreadLocal::get怎么用?C++ ThreadLocal::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ThreadLocal的用法示例。


在下文中一共展示了ThreadLocal::get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
        }
    }
}
开发者ID:RabidSQL,项目名称:backend,代码行数:25,代码来源:TestThreadLocal.cpp

示例2:

 virtual RequestHandler *createRequestHandler() {
     s_rpc_request_handler->setServerInfo(m_serverInfo);
     if (s_rpc_request_handler->needReset() ||
             s_rpc_request_handler->incRequest() > m_serverInfo->getMaxRequest()) {
         s_rpc_request_handler.reset();
         s_rpc_request_handler->setServerInfo(m_serverInfo);
         s_rpc_request_handler->incRequest();
     }
     return s_rpc_request_handler.get();
 }
开发者ID:brion,项目名称:hiphop-php,代码行数:10,代码来源:satellite_server.cpp

示例3: testAccessors

void ThreadLocalTest::testAccessors()
{
	ThreadLocal<TLTestStruct> ts;
	ts->i = 100;
	ts->s = "foo";
	assert ((*ts).i == 100);
	assert ((*ts).s == "foo");
	assert (ts.get().i == 100);
	assert (ts.get().s == "foo");
}
开发者ID:119,项目名称:vdc,代码行数:10,代码来源:ThreadLocalTest.cpp

示例4:

// 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);
}
开发者ID:RabidSQL,项目名称:backend,代码行数:12,代码来源:TestThreadLocal.cpp

示例5: operator

  inline void operator()()
  {
    staticThinggy = new Thinggy;
    staticThreadLocal.set(staticThinggy);
    waiting = true;
    gate.Set();
    waiter.Wait();
    waiting = false;

    threadLocalHadValue = staticThreadLocal.get() != NULL;
    gate.Set();
  }
开发者ID:Foozle303,项目名称:xbmc,代码行数:12,代码来源:TestThreadLocal.cpp

示例6: t

TEST(TestThreadLocal, Simple)
{
  GlobalThreadLocal runnable;
  thread t(runnable);

  gate.Wait();
  EXPECT_TRUE(runnable.waiting);
  EXPECT_TRUE(staticThinggy != NULL);
  EXPECT_TRUE(staticThreadLocal.get() == NULL);
  waiter.Set();
  gate.Wait();
  EXPECT_TRUE(runnable.threadLocalHadValue);
  EXPECT_TRUE(!destructorCalled);
  delete staticThinggy;
  EXPECT_TRUE(destructorCalled);
  cleanup();
}
开发者ID:0xheart0,项目名称:xbmc,代码行数:17,代码来源:TestThreadLocal.cpp

示例7: autoLock

BackgroundHangThread*
BackgroundHangThread::FindThread()
{
  if (sTlsKey.initialized()) {
    // Use TLS if available
    return sTlsKey.get();
  }
  // If TLS is unavailable, we can search through the thread list
  RefPtr<BackgroundHangManager> manager(BackgroundHangManager::sInstance);
  MOZ_ASSERT(manager, "Creating BackgroundHangMonitor after shutdown");

  PRThread* threadID = PR_GetCurrentThread();
  // Lock thread list for traversal
  MonitorAutoLock autoLock(manager->mLock);
  for (BackgroundHangThread* thread = manager->mHangThreads.getFirst();
       thread; thread = thread->getNext()) {
    if (thread->mThreadID == threadID) {
      return thread;
    }
  }
  // Current thread is not initialized
  return nullptr;
}
开发者ID:jpfreire,项目名称:mozilla-central,代码行数:23,代码来源:BackgroundHangMonitor.cpp

示例8: secureRandom

void Random::secureRandom(void* data, size_t size) {
  static ThreadLocal<BufferedRandomDevice> bufferedRandomDevice;
  bufferedRandomDevice->get(data, size);
}
开发者ID:1Hgm,项目名称:folly,代码行数:4,代码来源:Random.cpp

示例9: get

	int get() { return value.get(); }
开发者ID:elmagroud00,项目名称:Experiments,代码行数:1,代码来源:ThreadLocalVariables.cpp

示例10: increment

	void increment() { value.set(value.get() + 1); }
开发者ID:elmagroud00,项目名称:Experiments,代码行数:1,代码来源:ThreadLocalVariables.cpp

示例11:

NestedDiagnosticContext& NestedDiagnosticContext::current()
{
	static ThreadLocal<NestedDiagnosticContext> ndc;
	return ndc.get();
}
开发者ID:RangelReale,项目名称:sandbox,代码行数:5,代码来源:NestedDiagnosticContext.cpp

示例12:

TEST(ThreadLocalStorage, NotSetReturnsNull) {
    static ThreadLocal<int> number;

    EXPECT_EQ(nullptr, number.get());
}
开发者ID:AnithaGorli,项目名称:mapbox-gl-native,代码行数:5,代码来源:thread_local.cpp

示例13:

TEST(ThreadLocal, Unthreaded)
{
  EXPECT_EQ(sVar.get(), 0);
  sVar = 10;
  EXPECT_EQ(sVar.get(), 10);
}
开发者ID:alliedmodders,项目名称:amtl,代码行数:6,代码来源:test-threadlocal-unthreaded.cpp


注:本文中的ThreadLocal::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。