r419: various fixes, memory allocations, etc.
[cinelerra_cv/mob.git] / guicast / thread.h
blobf10a3a11b98cd6c5230604b5e7653d22bc8c938d
1 #ifndef THREAD_H
2 #define THREAD_H
4 #include <pthread.h>
6 // The thread does not autodelete by default.
7 // If autodelete is 1 the thread autodeletes.
8 // If it's synchronous the deletion occurs in join().
9 // If it's asynchronous the deletion occurs in entrypoint.
12 class Thread
14 private:
15 static void* entrypoint(void *parameters);
16 protected:
17 virtual void run() = 0;
18 public:
19 Thread(int synchronous = 0, int realtime = 0, int autodelete = 0);
20 virtual ~Thread();
21 void start();
22 int end(pthread_t tid); // end another thread
23 int end(); // end this thread
24 int cancel(); // end this thread
25 int join(); // join this thread
26 int suspend_thread(); // suspend this thread
27 int continue_thread(); // continue this thread
28 int exit_thread(); // exit this thread
29 int enable_cancel();
30 int disable_cancel();
31 int get_cancel_enabled();
32 int running(); // Return if thread is running
33 int set_synchronous(int value);
34 int set_realtime(int value = 1);
35 int set_autodelete(int value);
36 int get_autodelete();
37 int get_realtime(); // Return realtime variable
38 static int calculate_realtime(); // Determine status by querying kernel
39 int get_synchronous();
40 int get_tid();
42 private:
43 int synchronous; // set to 1 to force join() to end
44 int realtime; // set to 1 to schedule realtime
45 int autodelete; // set to 1 to autodelete when run() finishes
46 int thread_running;
47 pthread_t tid;
48 int cancel_enabled;
51 #endif