xref: /haiku/src/servers/registrar/mime/RegistrarThread.h (revision f75a7bf508f3156d63a14f8fd77c5e0ca4d08c42)
1 //----------------------------------------------------------------------
2 //  This software is part of the OpenBeOS distribution and is covered
3 //  by the OpenBeOS 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, BMessenger managerMessenger);
19 	virtual ~RegistrarThread();
20 
21 	virtual status_t InitCheck();
22 	status_t Run();
23 
24 	thread_id Id() const;
25 	const char* Name() const;
26 
27 	void AskToExit();
28 	bool IsFinished() const;
29 
30 protected:
31 	//! The function executed in the object's thread when Run() is called
32 	virtual status_t ThreadFunction() = 0;
33 
34 	BMessenger fManagerMessenger;
35 	bool fShouldExit;	// Initially false, may be set to true by AskToExit()
36 	bool fIsFinished;	// Initially false, set to true by the thread itself upon completion
37 private:
38 	static int32 EntryFunction(void *data);
39 
40 	status_t fStatus;
41 	thread_id fId;
42 	char fName[B_OS_NAME_LENGTH];
43 };
44 
45 #endif	// REGISTRAR_THREAD_H
46