From a5b45e8e2e99686ea73fa2793d7fec84f0d1a3ed Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 17 Dec 2002 04:36:31 +0000 Subject: "" svn path=/trunk/; revision=303 --- externals/grill/flext/source/flsupport.h | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'externals/grill/flext/source/flsupport.h') diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index 08036ff5..9429599d 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -391,6 +391,43 @@ public: @{ */ + //! thread type + typedef pthread_t thrid_t; + +protected: + //! system's thread id + static thrid_t thrid; // the system thread + +public: + + //! Check if current thread is the realtime system's thread + static bool IsSystemThread() { pthread_t cur = pthread_self(); return pthread_equal(cur,thrid) != 0; } + + /*! \brief Yield to other threads + \remark A call to this is only needed for systems with cooperative multitasking like MacOS<=9 + */ + static void ThrYield() { sched_yield(); } + + /*! \brief Get current thread id + */ + static thrid_t GetThreadId() { return pthread_self(); } + + /*! \brief Get current thread id + */ + static thrid_t GetSysThreadId() { return thrid; } + + /*! \brief Increase/Decrease priority of a thread + */ + static bool RelPriority(int dp,thrid_t ref = GetSysThreadId(),thrid_t thr = GetThreadId()); + + /*! \brief Get priority of a thread + */ + static int GetPriority(thrid_t thr = GetThreadId()); + + /*! \brief Set priority of a thread + */ + static bool SetPriority(int p,thrid_t thr = GetThreadId()); + /*! \brief Thread mutex \sa pthreads documentation */ -- cgit v1.2.1