use spaces instead of tab
This commit is contained in:
+82
-82
@@ -27,79 +27,79 @@
|
||||
* wrapper class for pthread.
|
||||
*/
|
||||
class Thread {
|
||||
public:
|
||||
/**
|
||||
* constructor.
|
||||
*/
|
||||
Thread() : m_threadid(0), m_started(false), m_running(false), m_stopped(false) {}
|
||||
public:
|
||||
/**
|
||||
* constructor.
|
||||
*/
|
||||
Thread() : m_threadid(0), m_started(false), m_running(false), m_stopped(false) {}
|
||||
|
||||
/**
|
||||
* virtual destructor.
|
||||
*/
|
||||
virtual ~Thread();
|
||||
/**
|
||||
* virtual destructor.
|
||||
*/
|
||||
virtual ~Thread();
|
||||
|
||||
/**
|
||||
* Thread entry helper for pthread_create.
|
||||
* @param arg pointer to the @a Thread.
|
||||
* @return NULL.
|
||||
*/
|
||||
static void* runThread(void* arg);
|
||||
/**
|
||||
* Thread entry helper for pthread_create.
|
||||
* @param arg pointer to the @a Thread.
|
||||
* @return NULL.
|
||||
*/
|
||||
static void* runThread(void* arg);
|
||||
|
||||
/**
|
||||
* Return whether this @a Thread is still running and not yet stopped.
|
||||
* @return true if this @a Thread is till running and not yet stopped.
|
||||
*/
|
||||
virtual bool isRunning() { return m_running && !m_stopped; }
|
||||
/**
|
||||
* Return whether this @a Thread is still running and not yet stopped.
|
||||
* @return true if this @a Thread is till running and not yet stopped.
|
||||
*/
|
||||
virtual bool isRunning() { return m_running && !m_stopped; }
|
||||
|
||||
/**
|
||||
* Create the native thread and set its name.
|
||||
* @param name the thread name to show in the process list.
|
||||
* @return whether the thread was started.
|
||||
*/
|
||||
virtual bool start(const char* name);
|
||||
/**
|
||||
* Create the native thread and set its name.
|
||||
* @param name the thread name to show in the process list.
|
||||
* @return whether the thread was started.
|
||||
*/
|
||||
virtual bool start(const char* name);
|
||||
|
||||
/**
|
||||
* Notify the thread that it shall stop.
|
||||
*/
|
||||
virtual void stop() { m_stopped = true; }
|
||||
/**
|
||||
* Notify the thread that it shall stop.
|
||||
*/
|
||||
virtual void stop() { m_stopped = true; }
|
||||
|
||||
/**
|
||||
* Join the thread.
|
||||
* @return whether the thread was joined.
|
||||
*/
|
||||
virtual bool join();
|
||||
/**
|
||||
* Join the thread.
|
||||
* @return whether the thread was joined.
|
||||
*/
|
||||
virtual bool join();
|
||||
|
||||
/**
|
||||
* Get the thread id.
|
||||
* @return the thread id.
|
||||
*/
|
||||
pthread_t self() { return m_threadid; }
|
||||
/**
|
||||
* Get the thread id.
|
||||
* @return the thread id.
|
||||
*/
|
||||
pthread_t self() { return m_threadid; }
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Thread entry method to be overridden by derived class.
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
protected:
|
||||
/**
|
||||
* Thread entry method to be overridden by derived class.
|
||||
*/
|
||||
virtual void run() = 0;
|
||||
|
||||
|
||||
private:
|
||||
/**
|
||||
* Enter the Thread loop by calling run().
|
||||
*/
|
||||
void enter();
|
||||
private:
|
||||
/**
|
||||
* Enter the Thread loop by calling run().
|
||||
*/
|
||||
void enter();
|
||||
|
||||
/** own thread id */
|
||||
pthread_t m_threadid;
|
||||
/** own thread id */
|
||||
pthread_t m_threadid;
|
||||
|
||||
/** Whether the thread was started. */
|
||||
bool m_started;
|
||||
/** Whether the thread was started. */
|
||||
bool m_started;
|
||||
|
||||
/** Whether the thread is still running (i.e. in @a run() ). */
|
||||
bool m_running;
|
||||
/** Whether the thread is still running (i.e. in @a run() ). */
|
||||
bool m_running;
|
||||
|
||||
/** Whether the thread was stopped by @a stop() or @a join(). */
|
||||
bool m_stopped;
|
||||
/** Whether the thread was stopped by @a stop() or @a join(). */
|
||||
bool m_stopped;
|
||||
};
|
||||
|
||||
|
||||
@@ -107,37 +107,37 @@ class Thread {
|
||||
* A @a Thread that can be waited on.
|
||||
*/
|
||||
class WaitThread : public Thread {
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
WaitThread();
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
WaitThread();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~WaitThread();
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~WaitThread();
|
||||
|
||||
// @copydoc
|
||||
virtual void stop();
|
||||
// @copydoc
|
||||
virtual void stop();
|
||||
|
||||
// @copydoc
|
||||
virtual bool join();
|
||||
// @copydoc
|
||||
virtual bool join();
|
||||
|
||||
/**
|
||||
* Wait for the specified amount of time.
|
||||
* @param seconds the number of seconds to wait.
|
||||
* @return true if this @a WaitThread is still running and not yet stopped.
|
||||
*/
|
||||
bool Wait(int seconds);
|
||||
/**
|
||||
* Wait for the specified amount of time.
|
||||
* @param seconds the number of seconds to wait.
|
||||
* @return true if this @a WaitThread is still running and not yet stopped.
|
||||
*/
|
||||
bool Wait(int seconds);
|
||||
|
||||
|
||||
private:
|
||||
/** the mutex for waiting. */
|
||||
pthread_mutex_t m_mutex;
|
||||
private:
|
||||
/** the mutex for waiting. */
|
||||
pthread_mutex_t m_mutex;
|
||||
|
||||
/** the condition for waiting. */
|
||||
pthread_cond_t m_cond;
|
||||
/** the condition for waiting. */
|
||||
pthread_cond_t m_cond;
|
||||
};
|
||||
|
||||
#endif // LIB_UTILS_THREAD_H_
|
||||
|
||||
Reference in New Issue
Block a user