libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
moThread.cpp
Ir a la documentación de este archivo.
1
/*******************************************************************************
2
3
moThread.cpp
4
5
****************************************************************************
6
* *
7
* This source is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* This code is distributed in the hope that it will be useful, but *
13
* WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15
* General Public License for more details. *
16
* *
17
* A copy of the GNU General Public License is available on the World *
18
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19
* obtain it by writing to the Free Software Foundation, *
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
* *
22
****************************************************************************
23
24
Copyright(C) 2006 Fabricio Costa
25
26
Authors:
27
Fabricio Costa
28
29
30
*******************************************************************************/
31
32
#include "
moThread.h
"
33
34
moThread::moThread
() {
35
m_handleThread
= NULL;
36
}
37
38
moThread::~moThread
() {
39
if
(
ThreadExists
())
40
KillThread
();
41
}
42
43
bool
moThread::CreateThread
() {
44
//thread* pthread;
45
//pthread = new thread( boost::bind( moThread::InitialThreadFunction, (void*)this ) );
46
//m_handleThread = (void*) pthread;
47
48
//m_handleThread = (void *)SDL_CreateThread( InitialThreadFunction,(void*)this);
49
#ifndef MO_WIN32
50
pthread_create( (pthread_t*)&
m_handleThread
, NULL,
InitialThreadFunction
,
this
);
51
#else
52
DWORD threadId;
53
m_handleThread = (
void
*) ::
CreateThread
( 0, 0,
InitialThreadFunction
,
this
, 0, &threadId );
54
#endif
55
56
return
(m_handleThread!=NULL);
57
}
58
59
bool
moThread::KillThread
() {
60
if
(
ThreadExists
()) {
61
/*
62
SDL_KillThread( (SDL_Thread *) m_handleThread );//SDL_WaitThread ???
63
*/
64
#ifndef MO_WIN32
65
pthread_cancel((pthread_t)
m_handleThread
);
66
#else
67
CloseHandle( m_handleThread );
68
#endif
69
//thread* pthread = (thread*)m_handleThread;
70
//delete pthread;
71
m_handleThread=NULL;
72
}
73
return
(
m_handleThread
==NULL);
74
}
75
bool
moThread::ThreadExists
() {
76
return
(
m_handleThread
!=NULL);
77
}
78
79
bool
moThread::SendThreadMessage
(
int
message
) {
80
if
(message<=0)
return
false
;
81
return
true
;
82
}
83
84
#ifndef WIN32
85
void
*
moThread::InitialThreadFunction
(
void
*data ) {
86
#else
87
DWORD WINAPI
moThread::InitialThreadFunction
( LPVOID data ) {
88
#endif
89
moThread
* m_pThreadClass;
90
m_pThreadClass =(
moThread
*)data;
91
int
b = m_pThreadClass->
ThreadUserFunction
();
92
#ifndef WIN32
93
return
(
void
*)0;
94
#else
95
return
b;
96
#endif
97
}
98
99
bool
moThread::ProcessMessage
() {
100
return
true
;
101
}
102
103
moThread::KillThread
bool KillThread()
Definition:
moThread.cpp:59
moThread::m_handleThread
moBoostThread m_handleThread
Definition:
moThread.h:69
moThread::InitialThreadFunction
static void * InitialThreadFunction(void *data)
Definition:
moThread.cpp:85
moThread::ThreadExists
bool ThreadExists()
Definition:
moThread.cpp:75
message
const char * message
Definition:
moTextureManager.cpp:41
moThread
Definition:
moThread.h:54
moThread::~moThread
virtual ~moThread()
Definition:
moThread.cpp:38
moThread::SendThreadMessage
bool SendThreadMessage(int message)
Definition:
moThread.cpp:79
moThread.h
moThread::moThread
moThread()
Definition:
moThread.cpp:34
moThread::ThreadUserFunction
virtual int ThreadUserFunction()=0
moThread::CreateThread
bool CreateThread()
Definition:
moThread.cpp:43
moThread::ProcessMessage
bool ProcessMessage()
Definition:
moThread.cpp:99
libmoldeo
moThread.cpp
Generado el Martes, 10 de Septiembre de 2019 21:27:08 para libmoldeo (Moldeo 1.0 Core) por
1.8.13