Exemple #1
0
TEST(IThread, Test1) {
  class ThreadHandle: public IThread {
   public:
    ThreadHandle():num(1) {}
    virtual ~ThreadHandle() {}
   private:
   public:
    virtual void run() {
      ASSERT_EQ(num, 1u);
      num = 2;
    }
   public:
    size_t num;
  };
  {
    ThreadHandle thr;
    thr.start();
    thr.join();
    ASSERT_EQ(thr.num, 2u);
  }
  {
    IThread* ptr = new ThreadHandle();
    ptr->start();
    ptr->join();
    delete ptr;
  }
}
Exemple #2
0
bool 
Thread::interrupted()
{
    ThreadHandle handle = currentThread();
  
    if(!handle.is_null()) {
        return handle->consumeInterruptionSync();
    } else {
        return false;
    }
};
Exemple #3
0
 /**
  * Determine if the current thread has locked this mutex.  This is a
  * debug-only method meant for assert() calls, and is not available
  * in optimised builds.
  */
 gcc_pure
 bool IsLockedByCurrent() const {
   debug_mutex.Lock();
   bool result = locked && owner.IsInside();
   debug_mutex.Unlock();
   return result;
 }
Exemple #4
0
void
LeaveDrawThread()
{
  assert(InMainThread());
  assert(draw_thread_handle.IsInside());

  draw_thread_handle = zero_thread_handle;
}
Exemple #5
0
bool
InDrawThread()
{
#ifdef ENABLE_OPENGL
  return InMainThread() && draw_thread_handle.IsInside();
#else
  return draw_thread != nullptr && draw_thread->IsInside();
#endif
}
Exemple #6
0
  /**
   * Unlocks the Mutex
   */
  void Unlock() {
#ifndef NDEBUG
    debug_mutex.lock();
    assert(locked);
    assert(owner.IsInside());
    locked = false;
    debug_mutex.unlock();
#endif

    mutex.unlock();
  }
Exemple #7
0
  /**
   * Unlocks the Mutex
   */
  void Unlock() {
#ifndef NDEBUG
    debug_mutex.Lock();
    assert(locked);
    assert(owner.IsInside());
    locked = false;
    debug_mutex.Unlock();
#endif

    mutex.Unlock();

#ifndef NDEBUG
    --thread_locks_held;
#endif
  }
Exemple #8
0
OVUM_API size_t VM_GetArgValues(ThreadHandle thread, size_t destLength, Value dest[])
{
	return thread->GetVM()->GetArgValues(destLength, dest);
}
Exemple #9
0
OVUM_API size_t VM_GetArgs(ThreadHandle thread, size_t destLength, String *dest[])
{
	return thread->GetVM()->GetArgs(destLength, dest);
}
Exemple #10
0
OVUM_API size_t VM_GetArgCount(ThreadHandle thread)
{
	return thread->GetVM()->GetArgCount();
}
Exemple #11
0
 void WakeUp() {
     if (!thread.IsInside())
         event_pipe.Signal();
 }
Exemple #12
0
    /**
     * Returns the monotonic clock in microseconds.  This method is only
     * available in the main thread.
     */
    gcc_pure
    uint64_t ClockUS() const {
        assert(thread.IsInside());

        return now_us;
    }
Exemple #13
0
bool
InMainThread()
{
  return main_thread.IsInside();
}