43 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
65 WARNING(
"Killing a running thread!");
99 DEBUG(
"Thread already stopped");
103 DEBUG(
"Cancelling thread...");
105 if (pthread_cancel(
handle_) == 0){
106 DEBUG(
"Thread succesfully canceled.");
121 if (pthread_join(
handle_, NULL) == 0){
122 DEBUG(
"Thread succesfully joined.");
142 if (pthread_sigmask(SIG_BLOCK, &m, NULL) != 0) {
143 ERROR(
"Can't mask signal " << sig);
163 if (pthread_sigmask(SIG_UNBLOCK, &m, NULL) != 0) {
164 ERROR(
"Can't unmask signal " << sig);
180 if (pthread_kill(
handle_, sig) != 0){
181 ERROR(
"Can't send signal " << sig);
209 sigset_t oldset,
set;
213 sigprocmask(SIG_SETMASK, &
set, &oldset);
214 bzero( &sa,
sizeof(sa) );
215 sa.sa_handler = handler;
216 if (sigaction(sig, &sa, NULL) < 0) {
217 ERROR(
"Can't set signal " << sig);
221 sigprocmask(SIG_SETMASK, &oldset,NULL);
235 struct sched_param p;
236 p.sched_priority = priority;
237 if (pthread_setschedparam(
handle_, policy, &p) == 0)
253 struct sched_param p;
254 int ret = pthread_getschedparam(
handle_, policy, &p);
255 *priority = p.sched_priority;
263 #if defined(ONPOSIX_LINUX_SPECIFIC) && defined(__GLIBC__) && \
264 ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ > 3)))
278 void AbstractThread::setAffinity(
const std::vector<bool>& v)
282 for (
unsigned int i = 0; (i < v.size()) && (i < CPU_SETSIZE); ++i)
286 if ((pthread_setaffinity_np(
handle_,
sizeof(s), &s) != 0))
287 throw std::runtime_error (
"Set affinity error");
302 void AbstractThread::getAffinity(std::vector<bool>* v)
307 if ((pthread_getaffinity_np(
handle_,
sizeof(s), &s) != 0))
308 throw std::runtime_error (
"Get affinity error");
310 for (
unsigned int j = 0; (j < CPU_SETSIZE) && (j < v->size()); ++j) {
311 if (CPU_ISSET(j, &s))