6#ifndef _ZFI_ZFThread_h_
7#define _ZFI_ZFThread_h_
338 _ZFP_ZFThreadPrivate *d;
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_DECLARE_STATIC_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:708
#define ZFMETHOD_DECLARE_PROTECTED_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:886
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1025
#define ZFMETHOD_DECLARE_STATIC_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1042
#define ZFMETHOD_DECLARE_STATIC_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:870
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
ZFObject related include.
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_ON_INIT_DECLARE_1(ZFMP_0)
see ZFOBJECT_ON_INIT_INLINE_1
Definition ZFObjectDeclare.h:263
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
listener data used by ZFListener
Definition ZFArgs.h:20
light weight array
Definition ZFCoreArray.h:331
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
static ZFThread * currentThread()
return current thread, or zfnull if thread isn't started or registered by ZFThread or not registered ...
virtual void taskQueueInit()
prepare a task queue that can be run in this thread
static zfbool sleep(zftimet miliSecs)
make current thread sleep for miliSecs, note this method may be not accurate
virtual void threadOnStopRequested(void)
see E_ThreadOnStopRequested
Definition ZFThread.h:329
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
virtual void autoReleasePoolAdd(ZFObject *obj)
add object to auto release pool attached to this thread
static zfidentity E_ThreadOnStop(void)
see ZFObject::observerNotify
virtual void threadTaskQueueOnFinish(void)
see E_ThreadTaskQueueOnFinish
Definition ZFThread.h:333
virtual void threadWait()
wait until thread finished running
static zfidentity E_ThreadOnStart(void)
see ZFObject::observerNotify
virtual void objectInfoImplAppend(zfstring &ret)
see objectInfo
virtual void autoReleasePoolDrain()
manually drain auto release pool
virtual zfbool threadRunning()
return true only if thread is running
virtual void threadStart(ZFObject *param0=(zft_zfnull), ZFObject *param1=(zft_zfnull))
start thread, do nothing if already started
virtual zfbool taskQueueRunning()
try if any task add by taskQueueAdd is running
virtual void objectOnDealloc(void)
override this to destroy your object
static ZFThread * executeInThread(ZFThread *thread, const ZFListener &callback)
util to run callback in specified thread, or run in mainThread if the thread is null or taskQueueAvai...
virtual void threadOnRun(const ZFArgs &zfargs)
internal runnable, do nothing by default, you may override it
virtual void taskQueueCleanup()
see taskQueueInit
virtual zfbool isMainThread()
return true if current thread is main thread
virtual void objectOnInit(const ZFListener &runnable)
init from listener
static zfidentity E_ThreadOnStopRequested(void)
see ZFObject::observerNotify
virtual void threadOnUnregister(void)
see E_ThreadOnUnregister
Definition ZFThread.h:317
virtual void sleepCancel()
cancel sleep or do nothing if not sleepping
static void * nativeThreadRegister(const zfstring &threadName)
register a thread which is not started by ZFThread, assert fail if already registered
static zfidentity E_ThreadOnUnregister(void)
see ZFObject::observerNotify
static void nativeThreadUnregister(void *token)
see nativeThreadRegister
virtual void threadOnStart(const ZFArgs &zfargs)
see E_ThreadOnStart
Definition ZFThread.h:321
static zfidentity E_ThreadTaskQueueOnFinish(void)
see ZFObject::observerNotify
virtual zfstring & threadName()
thread name for debug use
Definition ZFThread.h:173
static zfidentity E_ThreadOnRegister(void)
see ZFObject::observerNotify
virtual void threadStop()
request stop the thread, may not be stopped immediately
virtual zfbool isNativeThread()
true if the thread is registered by nativeThreadRegister
static ZFThread * mainThread()
return main thread
virtual void threadOnStop(const ZFArgs &zfargs)
see E_ThreadOnStop
Definition ZFThread.h:325
static const ZFCoreArray< ZFThread * > & allThread()
access all thread, mainThread is not included
virtual ZFListener & threadRunnable()
the main callback to run
Definition ZFThread.h:183
virtual void taskQueueRemove(const ZFListener &task)
see taskQueueRemove
virtual zfbool taskQueueAvailable()
see taskQueueInit
virtual void taskQueueAdd(const ZFListener &task)
see taskQueueInit
virtual zfbool threadStarted()
return true if start is called and hasn't been stopped or end
virtual void threadOnRegister(void)
see E_ThreadOnRegister
Definition ZFThread.h:313
static zfbool implAvailable()
whether thread impl is available
virtual zfbool threadStopRequested()
return true if stop is called after start
virtual zfindex taskQueueCount()
see taskQueueInit
static zfbool implMainThreadTaskAvailable()
whether mainThread's taskQueueAdd is available