Subversion Repositories HomeAutomation

Rev

Rev 1317 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1317 Rev 1403
Line 12... Line 12...
12
namespace atom {
12
namespace atom {
13
namespace thread {
13
namespace thread {
14
 
14
 
15
Thread::Thread()
15
Thread::Thread()
16
{
16
{
17
    this->myIsRunning = false;
17
    this->is_running_ = false;
18
}
18
}
19
 
19
 
20
Thread::~Thread()
20
Thread::~Thread()
21
{
21
{
22
    //cout << "Thread destroy" << endl;
22
    //cout << "Thread destroy" << endl;
23
    this->stop();
23
    this->Stop();
24
}
24
}
25
 
25
 
26
void Thread::start()
26
void Thread::Start()
27
{
27
{
28
    if (!this->myIsRunning)
28
    if (!this->is_running_)
29
    {
29
    {
30
        boost::thread localThread(boost::bind(&Thread::runBase, this));
30
        boost::thread localThread(boost::bind(&Thread::RunBase, this));
31
        this->myThread = localThread.move();
31
        this->thread_ = localThread.move();
32
        this->myIsRunning = true;
32
        this->is_running_ = true;
33
    }
33
    }
34
}
34
}
35
 
35
 
36
void Thread::stop()
36
void Thread::Stop()
37
{
37
{
38
    this->myThread.interrupt();
38
    this->thread_.interrupt();
39
    this->myThread.join();
39
    this->thread_.join();
40
    this->myIsRunning = false;
40
    this->is_running_ = false;
41
}
41
}
42
 
42
 
43
boost::thread::id Thread::getId()
43
boost::thread::id Thread::GetId()
44
{
44
{
45
    return this->myThread.get_id();
45
    return this->thread_.get_id();
46
}
46
}
47
 
47
 
48
bool Thread::isRunning()
48
bool Thread::IsRunning()
49
{
49
{
50
    return this->myIsRunning;
50
    return this->is_running_;
51
}
51
}
52
 
52
 
53
void Thread::runBase()
53
void Thread::RunBase()
54
{
54
{
55
    this->myIsRunning = true;
55
    this->is_running_ = true;
56
    this->run();
56
    this->Run();
57
    this->myIsRunning = false;
57
    this->is_running_ = false;
58
}
58
}
59
 
59
 
60
void Thread::run()
60
} // namespace thread
61
{
-
 
62
}
-
 
63
 
-
 
64
}
61
} // namespace atom
65
}
-