win32/pthreads の周りに C++ スレッド ラッパー クラスがあります。問題はヘッダーにあります。以下で typedef を宣言するために、windows.h や boost::function などの大きなインクルードが必要です。
これを回避する方法はありますか?クラスと構造体を前方宣言できることは知っていますが、win32 HANDLE のようなデータ型と名前空間のテンプレート化された関数は...?
#include "boost/function.hpp"
/* Thread wrapper class */
class IThread
{
public:
#if defined _WIN32 || _WIN64
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#undef WIN32_LEAN_AND_MEAN
typedef HANDLE ThreadHandle;
#else
#include <pthread.h>
typedef pthread_t ThreadHandle;
#endif
enum ThreadState
{
DETACHED = 0,
RUNNING,
FINISHED
};
typedef boost::function1<void, void*> Task;
virtual ~IThread() { }
IThread& operator=(IThread& other);
virtual int32_t Join() = 0;
virtual int32_t SetPriority(int32_t priority) = 0;
virtual ThreadHandle& GetNativeHandle() = 0;
virtual ThreadState GetThreadState() const = 0;
};
ありがとう