tahoma2d/toonz/sources/stdfx/igs_resource_thread.h

56 lines
2 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef igs_resource_thread_h
#define igs_resource_thread_h
2016-06-15 18:43:10 +12:00
#if defined _WIN32 //-------------------------------------------------
#include <windows.h> // HANDLE
#include <process.h> // _beginthreadex()
2016-03-19 06:57:51 +13:00
#ifndef IGS_RESOURCE_IFX_EXPORT
#define IGS_RESOURCE_IFX_EXPORT
#endif
2016-06-15 18:43:10 +12:00
namespace igs {
namespace resource {
// HANDLE = unsigned long(vc6.0) = void *(vc2005)
2016-03-19 06:57:51 +13:00
IGS_RESOURCE_IFX_EXPORT const HANDLE thread_run(
2016-06-15 18:43:10 +12:00
unsigned(__stdcall *function)(void *), void *func_arg,
const int priority = THREAD_PRIORITY_NORMAL
/*
priorityに与える値を優先度の高いものから順に並べます
THREAD_PRIORITY_TIME_CRITICAL 15 or 31
THREAD_PRIORITY_HIGHEST 2
THREAD_PRIORITY_ABOVE_NORMAL 1
THREAD_PRIORITY_NORMAL
THREAD_PRIORITY_BELOW_NORMAL 1
THREAD_PRIORITY_LOWEST 2
THREAD_PRIORITY_IDLE 1 or 16
*/
);
2016-03-19 06:57:51 +13:00
IGS_RESOURCE_IFX_EXPORT const bool thread_was_done(const HANDLE thread_id);
IGS_RESOURCE_IFX_EXPORT void thread_join(const HANDLE thread_id);
IGS_RESOURCE_IFX_EXPORT void thread_wait(const HANDLE thread_id);
IGS_RESOURCE_IFX_EXPORT void thread_close(const HANDLE thread_id);
}
}
2016-06-15 18:43:10 +12:00
#else //--------------------------------------------------------------
#include <pthread.h> // pthread_t,pthread_create(),pthread_join()
namespace igs {
namespace resource {
// pthread_t = unsigned long int(rhel4)
2016-03-19 06:57:51 +13:00
pthread_t thread_run(
2016-06-15 18:43:10 +12:00
void *(*function)(void *), void *func_arg,
const int state = PTHREAD_CREATE_JOINABLE
/*
state
PTHREAD_CREATE_JOINABLE pthread_join()
PTHREAD_CREATE_DETACHED
thread終了を知るには自前で仕掛けが必要
*/
);
2016-03-19 06:57:51 +13:00
void thread_join(const pthread_t thread_id);
}
}
2016-06-15 18:43:10 +12:00
#endif //-------------------------------------------------------------
2016-03-19 06:57:51 +13:00
#endif /* !igs_resource_thread_h */