Panda3D

threadDummyImpl.h

00001 // Filename: threadDummyImpl.h
00002 // Created by:  drose (09Aug02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef THREADDUMMYIMPL_H
00016 #define THREADDUMMYIMPL_H
00017 
00018 #include "pandabase.h"
00019 #include "selectThreadImpl.h"
00020 
00021 #ifdef THREAD_DUMMY_IMPL
00022 
00023 #include "pnotify.h"
00024 #include "threadPriority.h"
00025 
00026 class Thread;
00027 
00028 #ifdef WIN32
00029 #define WIN32_LEAN_AND_MEAN
00030 #include <windows.h>  // For Sleep().
00031 #endif
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : ThreadDummyImpl
00035 // Description : A fake thread implementation for single-threaded
00036 //               applications.  This simply fails whenever you try to
00037 //               start a thread.
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDA_PIPELINE ThreadDummyImpl {
00040 public:
00041   INLINE ThreadDummyImpl(Thread *parent_obj);
00042   INLINE ~ThreadDummyImpl();
00043 
00044   INLINE void setup_main_thread();
00045   INLINE bool start(ThreadPriority priority, bool joinable);
00046   INLINE void join();
00047   INLINE void preempt();
00048 
00049   string get_unique_id() const;
00050 
00051   INLINE static void prepare_for_exit();
00052 
00053   static Thread *get_current_thread();
00054   INLINE static void bind_thread(Thread *thread);
00055   INLINE static bool is_threading_supported();
00056   INLINE static bool is_true_threads();
00057   INLINE static bool is_simple_threads();
00058   INLINE static void sleep(double seconds);
00059   INLINE static void yield();
00060   INLINE static void consider_yield();
00061 };
00062 
00063 #include "threadDummyImpl.I"
00064 
00065 #endif // THREAD_DUMMY_IMPL
00066 
00067 #endif
 All Classes Functions Variables Enumerations