xref: /haiku/src/servers/registrar/mime/RegistrarThread.h (revision 9642f7705b27e5c270c15fa526d14e1848c2c27d)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the MIT License.
4 //---------------------------------------------------------------------
5 /*!
6 	\file RegistrarThread.h
7 	RegistrarThread interface declaration
8 */
9 
10 #ifndef REGISTRAR_THREAD_H
11 #define REGISTRAR_THREAD_H
12 
13 #include <Messenger.h>
14 #include <OS.h>
15 
16 class RegistrarThread {
17 public:
18 	RegistrarThread(const char *name, int32 priority,
19 		BMessenger managerMessenger);
20 	virtual ~RegistrarThread();
21 
22 	virtual status_t InitCheck();
23 	status_t Run();
24 
25 	thread_id Id() const;
26 	const char* Name() const;
27 
28 	void AskToExit();
29 	bool IsFinished() const;
30 
31 protected:
32 	//! The function executed in the object's thread when Run() is called
33 	virtual status_t ThreadFunction() = 0;
34 
35 	BMessenger fManagerMessenger;
36 	bool fShouldExit;	// Initially false, may be set to true by AskToExit()
37 	bool fIsFinished;	// Initially false, set to true by the thread itself
38 						// upon completion
39 private:
40 	static int32 EntryFunction(void *data);
41 
42 	status_t fStatus;
43 	thread_id fId;
44 	char fName[B_OS_NAME_LENGTH];
45 	int32 fPriority;
46 };
47 
48 #endif	// REGISTRAR_THREAD_H
49