|
Toshihiro Shimizu |
890ddd |
#ifndef igs_resource_thread_h
|
|
Toshihiro Shimizu |
890ddd |
#define igs_resource_thread_h
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#if defined _WIN32 //-------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include <windows.h> // HANDLE</windows.h>
|
|
Toshihiro Shimizu |
890ddd |
#include <process.h> // _beginthreadex()</process.h>
|
|
Toshihiro Shimizu |
890ddd |
#ifndef IGS_RESOURCE_IFX_EXPORT
|
|
Toshihiro Shimizu |
890ddd |
#define IGS_RESOURCE_IFX_EXPORT
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
namespace igs
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
namespace resource
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//HANDLE = unsigned long(vc6.0) = void *(vc2005)
|
|
Toshihiro Shimizu |
890ddd |
IGS_RESOURCE_IFX_EXPORT const HANDLE thread_run(
|
|
Toshihiro Shimizu |
890ddd |
unsigned(__stdcall *function)(void *), void *func_arg, const int priority = THREAD_PRIORITY_NORMAL
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
priorityに与える値を優先度の高いものから順に並べます。
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_TIME_CRITICAL プロセスにより15 or 31
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_HIGHEST 標準より2ポイント高い
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_ABOVE_NORMAL 標準より1ポイント高い
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_NORMAL 標準
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_BELOW_NORMAL 標準より1ポイント低い
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_LOWEST 標準より2ポイント低い
|
|
Toshihiro Shimizu |
890ddd |
THREAD_PRIORITY_IDLE プロセスにより1 or 16
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
IGS_RESOURCE_IFX_EXPORT const bool thread_was_done(const HANDLE thread_id);
|
|
Toshihiro Shimizu |
890ddd |
IGS_RESOURCE_IFX_EXPORT void thread_join(const HANDLE thread_id);
|
|
Toshihiro Shimizu |
890ddd |
IGS_RESOURCE_IFX_EXPORT void thread_wait(const HANDLE thread_id);
|
|
Toshihiro Shimizu |
890ddd |
IGS_RESOURCE_IFX_EXPORT void thread_close(const HANDLE thread_id);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#else //--------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
#include <pthread.h> // pthread_t,pthread_create(),pthread_join()</pthread.h>
|
|
Toshihiro Shimizu |
890ddd |
namespace igs
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
namespace resource
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//pthread_t = unsigned long int(rhel4)
|
|
Toshihiro Shimizu |
890ddd |
pthread_t thread_run(
|
|
Toshihiro Shimizu |
890ddd |
void *(*function)(void *), void *func_arg, const int state = PTHREAD_CREATE_JOINABLE
|
|
Toshihiro Shimizu |
890ddd |
/*
|
|
Toshihiro Shimizu |
890ddd |
state が
|
|
Toshihiro Shimizu |
890ddd |
PTHREAD_CREATE_JOINABLE なら、pthread_join()を呼んで終了を待つ
|
|
Toshihiro Shimizu |
890ddd |
PTHREAD_CREATE_DETACHED なら、なにも呼ぶ必要がないが、
|
|
Toshihiro Shimizu |
890ddd |
thread終了を知るには自前で仕掛けが必要。
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
);
|
|
Toshihiro Shimizu |
890ddd |
void thread_join(const pthread_t thread_id);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
#endif //-------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif /* !igs_resource_thread_h */
|