1 // license: public domain
2 // authors: jonas.sundstrom@kirilla.com
3 #ifndef _GENERIC_THREAD_H
4 #define _GENERIC_THREAD_H
14 const char* threadName
= "generic_thread",
15 int32 priority
= B_NORMAL_PRIORITY
,
16 BMessage
* message
= NULL
);
17 virtual ~GenericThread(void);
19 BMessage
* GetDataStore(void);
20 void SetDataStore(BMessage
* message
);
23 status_t
Pause(bool shouldBlock
= true,
24 bigtime_t timeout
= 0);
27 bool HasQuitBeenRequested(void);
29 status_t
Suspend(void);
30 status_t
Resume(void);
33 void ExitWithReturnValue(status_t returnValue
);
34 status_t
SetExitCallback(void (*callback
)(void*),
36 status_t
WaitForThread(status_t
* exitValue
);
38 status_t
Rename(char* name
);
40 status_t
SendData(int32 code
, void* buffer
,
42 int32
ReceiveData(thread_id
* sender
, void* buffer
,
46 status_t
SetPriority(int32 priority
);
48 void Snooze(bigtime_t delay
);
49 void SnoozeUntil(bigtime_t delay
,
50 int timeBase
= B_SYSTEM_TIMEBASE
);
52 status_t
GetInfo(thread_info
* info
);
53 thread_id
GetThread(void);
54 team_id
GetTeam(void);
56 thread_state
GetState(void);
57 sem_id
GetSemaphore(void);
58 int32
GetPriority(void);
59 bigtime_t
GetUserTime(void);
60 bigtime_t
GetKernelTime(void);
61 void* GetStackBase(void);
62 void* GetStackEnd(void);
65 virtual status_t
ThreadFunction(void);
66 virtual status_t
ThreadStartup(void);
67 virtual status_t
ExecuteUnit(void);
68 virtual status_t
ThreadShutdown(void);
70 virtual void ThreadStartupFailed(status_t status
);
71 virtual void ExecuteUnitFailed(status_t status
);
72 virtual void ThreadShutdownFailed(status_t status
);
75 // acquire m_execute_cycle
77 // release m_execute_cycle
79 BMessage
* fThreadDataStore
;
82 static status_t
private_thread_function(void* pointer
);
87 // acquire/relase within tread_function...
95 #endif // _GENERIC_THREAD_H