diff options
author | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-03-19 23:06:26 +0000 |
---|---|---|
committer | Travis CI <zmoelnig@travis-ci.umlaeute.mur.at> | 2015-03-19 23:06:26 +0000 |
commit | bdae26678d39c83280ed5e353986705da6f423c5 (patch) | |
tree | a977d9c7a25b275245787de02830a05e30fa0fb9 /Gem/develop/include/Gem/Utils/Thread.h | |
parent | 095b7e513f736567848173f2572d8b329ad75af9 (diff) |
Gem 4990e2aec04f67a68fbd2878f4d99bb8042f68fa osx/x86_64
built 'master:4990e2aec04f67a68fbd2878f4d99bb8042f68fa' for osx/x86_64
Diffstat (limited to 'Gem/develop/include/Gem/Utils/Thread.h')
-rw-r--r-- | Gem/develop/include/Gem/Utils/Thread.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Gem/develop/include/Gem/Utils/Thread.h b/Gem/develop/include/Gem/Utils/Thread.h new file mode 100644 index 0000000..ca861cc --- /dev/null +++ b/Gem/develop/include/Gem/Utils/Thread.h @@ -0,0 +1,66 @@ +/*----------------------------------------------------------------- +LOG + GEM - Graphics Environment for Multimedia + + Thread.h + - part of GEM + - simple platform independent thread abstraction + + Copyright (c) 2011-2012 IOhannes m zmölnig. forum::für::umläute. IEM. zmoelnig@iem.at + For information on usage and redistribution, and for a DISCLAIMER OF ALL + WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + +-----------------------------------------------------------------*/ + +#ifndef _INCLUDE__GEM_GEM_THREAD_H_ +#define _INCLUDE__GEM_GEM_THREAD_H_ + +#include "Gem/ExportDef.h" + +namespace gem { namespace thread { + /** + * get the number of available CPUs on the system + */ + GEM_EXTERN unsigned int getCPUCount(void); + + class GEM_EXTERN Thread { + private: + class PIMPL; + PIMPL*m_pimpl; + friend class PIMPL; + + Thread(const Thread&); + Thread&operator=(const Thread&); + public: + Thread(void); + virtual ~Thread(void); + + //// + // start thread + virtual bool start(void); + //// + // stop thread + // waits for at most wait4usec microseconds + // is wait4usec==0, waits until process terminates (e.g. forever) + virtual bool stop(unsigned int wait4usec=0); + + protected: + //// + // the worker! + // get's called from an alternative thread + // if TRUE is returned, process() will be called again + // until stop() is called + // if FALSE is returned, the thread may exit + virtual bool process(void) = 0; + }; + + + //////// + // wrapper around select() or whatever + GEM_EXTERN void usleep(unsigned long usec); +};}; // namespace + + + + +#endif /* _INCLUDE__GEM_GEM_THREAD_H_ */ |