File: ThreadWorker.cpp

package info (click to toggle)
yade 2017.01a-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,316 kB
  • ctags: 10,827
  • sloc: cpp: 52,081; python: 25,506; ansic: 6,463; sh: 109; makefile: 55
file content (77 lines) | stat: -rw-r--r-- 1,695 bytes parent folder | download | duplicates (10)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*************************************************************************
*  Copyright (C) 2006 by Janek Kozicki                                   *
*  cosurgi@berlios.de                                                    *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/

#include "ThreadWorker.hpp"

void ThreadWorker::setTerminate(bool b)
{
	boost::mutex::scoped_lock lock(m_mutex);
	m_should_terminate=b;
};

bool ThreadWorker::shouldTerminate()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_should_terminate;
};
		
void ThreadWorker::setProgress(float i)
{
	boost::mutex::scoped_lock lock(m_mutex);
	m_progress=i;
};

void ThreadWorker::setStatus(std::string s)
{
	boost::mutex::scoped_lock lock(m_mutex);
	m_status=s;
};

float ThreadWorker::progress()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_progress;
};

std::string ThreadWorker::getStatus()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_status;
};

void ThreadWorker::setReturnValue(boost::any a)
{
	boost::mutex::scoped_lock lock(m_mutex);
	m_val = a;
};

boost::any ThreadWorker::getReturnValue()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_val;
};

bool ThreadWorker::done()
{
	boost::mutex::scoped_lock lock(m_mutex);
	return m_done;
};

void ThreadWorker::callSingleAction()
{
	{
		boost::mutex::scoped_lock lock(m_mutex);
		m_done = false;
	}
	this->singleAction();
	{
		boost::mutex::scoped_lock lock(m_mutex);
		m_done = true;
	}
};