IMP
2.0.1
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
threads.h
Go to the documentation of this file.
1
/**
2
* \file IMP/base/threads.h
3
* \brief Control for using multiple threads in IMP
4
*
5
* Copyright 2007-2013 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef IMPBASE_THREADS_H
10
#define IMPBASE_THREADS_H
11
#include "
raii_macros.h
"
12
#include <IMP/base/base_config.h>
13
14
IMPBASE_BEGIN_NAMESPACE
15
16
/** \name Number of threads
17
Get and set the default number of threads to use in \imp.
18
@{ */
19
/** Get the current number of threads requested. */
20
IMPBASEEXPORT
unsigned
int
get_number_of_threads
();
21
/** Set the current number of threads to a number greater or
22
equal to 1. Setting it to 1 disables multithreaded evaluation.
23
*/
24
IMPBASEEXPORT
void
set_number_of_threads
(
unsigned
int
n);
25
/** @} */
26
27
28
/** Temporarily set the number of threads
29
*/
30
class
SetNumberOfThreads
:
public
base::RAII
31
{
32
int
num_;
33
public
:
34
IMP_RAII
(
SetNumberOfThreads
, (
unsigned
int
n),
35
{num_= 0;},
36
{
37
num_=
get_number_of_threads
();
38
set_number_of_threads
(n);
39
},
40
{
41
set_number_of_threads
(num_);
42
num_=0;
43
}, );
44
};
45
46
IMPBASE_END_NAMESPACE
47
48
#endif
/* IMPBASE_THREADS_H */