summaryrefslogtreecommitdiffstats
path: root/HBThread.cpp
blob: b36462be06b844151fb5f4acb582042f221950f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* $Id: HBThread.cpp,v 1.3 2003/08/24 13:27:41 titer Exp $ */

#include "HBCommon.h"
#include "HBThread.h"

#include <OS.h>

HBThread::HBThread( char * name, int priority = B_LOW_PRIORITY )
{
    fName = strdup( name );
    fThread = spawn_thread( ThreadFunc, fName, priority, this );
}

HBThread::~HBThread()
{
    fDie = true;
    Log( "Stopping thread %d (\"%s\")", fThread, fName );
    int32 exit_value;
    wait_for_thread( fThread, &exit_value );
    Log( "Thread %d stopped (\"%s\")", fThread, fName );
    free( fName );
}

void HBThread::Run()
{
    fDie = false;
    resume_thread( fThread );
    Log( "Thread %d started (\"%s\")", fThread, fName );
}

void HBThread::Suspend()
{
    suspend_thread( fThread );
}

void HBThread::Resume()
{
    resume_thread( fThread );
}

long HBThread::ThreadFunc( HBThread * _this )
{
    _this->DoWork();
    return 0;
}

void HBThread::DoWork()
{
}