vdk 2.4.0
vdkthread.h
1/*
2 * ===========================
3 * VDK Visual Development Kit
4 * Version 0.6
5 * Jan 1999
6 * ===========================
7 *
8 * Copyright (C) 1999, Salmaso Raffaele
9 * Developed by Salmaso Raffaele <r.salmaso@flashnet.it>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
20 *
21 * You should have received a copy of the GNU Library General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 * 02111-1307, USA.
25 */
26
27#ifndef VDKTHREAD_H
28#define VDKTHREAD_H
29
30#include <pthread.h>
31
32enum VDKMutexEnum {
33 VDKMUTEX_OK = 0,
34 VDKMUTEX_ERROR
35};
39enum VDKThreadEnum {
40 VDKTHREAD_IDLE = 1,
41 VDKTHREAD_RUNNING,
42 VDKTHREAD_STOPPED,
43 VDKTHREAD_EXITED,
44 VDKTHREAD_CANNOT_CREATE,
45 VDKTHREAD_IS_YET_RUNNING
46};
47
48class VDKMutex {
49private:
50 pthread_mutex_t mutex;
51public:
52 VDKMutex ();
53 ~VDKMutex ();
54 VDKMutexEnum Wait (long time = 0);
55 VDKMutexEnum Release ();
56 VDKMutexEnum Lock ();
57};
58
92class VDKThread {
93protected:
94 pthread_t id;
98 void Exit (void * status = 0);
99 static void * EntryPoint (void * arg);
100 virtual void Execute ();
101public:
102 VDKThread ();
103 virtual ~VDKThread ();
107 VDKThreadEnum Start (void * = NULL);
111 VDKThreadEnum Stop ();
115 void * Wait ();
119 VDKThreadEnum state;
123 unsigned int GetID () {return (unsigned long) id;};
124};
125
126#endif
This class provides a simple thread implementation Actually is supported only POSIX THREAD.
Definition: vdkthread.h:92
void * Wait()
Definition: vdkthread.cc:111
VDKThreadEnum state
Definition: vdkthread.h:119
unsigned int GetID()
Definition: vdkthread.h:123
VDKThreadEnum Stop()
Definition: vdkthread.cc:99
void Exit(void *status=0)
Definition: vdkthread.cc:106
VDKThreadEnum Start(void *=NULL)
Definition: vdkthread.cc:62