Use auto_ptr<> for pImpl Eliminate redundant ThreadListElement class. It just contains a Thread* and a ThreadListNode which contains itself? Make thread main function a static class function to avoid problems with accessing private members of ThreadPvt. In this context "private" means used by the implementation class only.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
/* thread.h */
|
|
/**
|
|
* Copyright - See the COPYRIGHT that is included with this distribution.
|
|
* EPICS pvDataCPP is distributed subject to a Software License Agreement found
|
|
* in file LICENSE that is included with this distribution.
|
|
*/
|
|
#ifndef THREAD_H
|
|
#define THREAD_H
|
|
#include <memory>
|
|
#include "noDefaultMethods.h"
|
|
#include "pvType.h"
|
|
|
|
namespace epics { namespace pvData {
|
|
|
|
enum ThreadPriority {
|
|
lowestPriority,
|
|
lowerPriority,
|
|
lowPriority,
|
|
middlePriority,
|
|
highPriority,
|
|
higherPriority,
|
|
highestPriority
|
|
};
|
|
|
|
class ThreadPriorityFunc {
|
|
public:
|
|
static unsigned int const * const getEpicsPriorities();
|
|
static int getEpicsPriority(ThreadPriority threadPriority);
|
|
};
|
|
|
|
class Runnable{
|
|
public:
|
|
virtual void run() = 0;
|
|
};
|
|
|
|
class Thread;
|
|
|
|
class Thread : private NoDefaultMethods {
|
|
public:
|
|
Thread(String name,ThreadPriority priority,Runnable *runnable);
|
|
~Thread();
|
|
String getName();
|
|
ThreadPriority getPriority();
|
|
static void showThreads(StringBuilder buf);
|
|
static void sleep(double seconds);
|
|
private:
|
|
class ThreadPvt;
|
|
std::auto_ptr<ThreadPvt> pImpl;
|
|
};
|
|
|
|
}}
|
|
#endif /* THREAD_H */
|