void* InternalThread::run(void* ptr) { InternalThread* thread = reinterpret_cast<InternalThread*>(ptr); VM* vm = thread->vm(); SharedState& shared = vm->shared; State state_obj(vm), *state = &state_obj; vm->set_current_thread(); vm->set_run_state(ManagedThread::eIndependent); RUBINIUS_THREAD_START( const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 1); NativeMethod::init_thread(state); thread->thread_running_ = true; thread->run(state); thread->thread_running_ = false; NativeMethod::cleanup_thread(state); RUBINIUS_THREAD_STOP( const_cast<RBX_DTRACE_CHAR_P>(vm->name().c_str()), vm->thread_id(), 1); shared.gc_independent(); return 0; }
TEST_F(InternalThreadTest, TestStartAndExit) { InternalThread thread; EXPECT_FALSE(thread.is_started()); thread.StartInternalThread(Caffe::Get().GetDefaultDevice()); EXPECT_TRUE(thread.is_started()); thread.StopInternalThread(); EXPECT_FALSE(thread.is_started()); }
TEST_F(InternalThreadTest, TestStartAndExit) { InternalThread thread; EXPECT_FALSE(thread.is_started()); EXPECT_TRUE(thread.StartInternalThread()); EXPECT_TRUE(thread.is_started()); EXPECT_TRUE(thread.WaitForInternalThreadToExit()); EXPECT_FALSE(thread.is_started()); }