1 /***************************************************************************
2 * Copyright (C) 2009 by Stefan Fuhrmann *
3 * stefanfuhrmann@alice-dsl.de *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 /// the actual thread function
29 void CThread::ThreadFunc (void* arg
)
31 // CCrashReportThread crashthread;
32 CThread
* self
= reinterpret_cast<CThread
*>(arg
);
34 // maybe, we were started in "suspended" mode
37 self
->resume
.WaitFor();
41 while (!self
->terminated
)
43 if ((*self
->func
)(self
->args
))
47 self
->terminated
= true;
55 self
->resume
.WaitFor();
58 // indicate that the thread is no longer processing any data
63 /// auto-start thread during construction
65 CThread::CThread (bool (*func
)(void *), void* args
, bool startSuspended
)
68 , suspended (startSuspended
)
72 thread
= _beginthread (&ThreadFunc
, 0, this);
75 CThread::~CThread(void)
83 void CThread::Suspend()
89 void CThread::Resume()
95 void CThread::Terminate()