-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPIProcessFactory.h
51 lines (35 loc) · 1.26 KB
/
MPIProcessFactory.h
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
/*
* MPIProcessFactory.h
*
* Created on: Jul 7, 2014
* Author: jrw32
*/
#ifndef MPIPROCESSFACTORY_H
#define MPIPROCESSFACTORY_H
#include <utility>
#include <map>
#include <string>
#include <deque>
#include <utility>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
typedef void (calcFunc)(unsigned int, const char*, std::deque<std::pair<unsigned int, const char*> >&, boost::mutex&, boost::condition_variable&);
namespace PLATO{
class MPIProcessFactory{
private:
MPIProcessFactory(){}
MPIProcessFactory(const MPIProcessFactory&);
MPIProcessFactory& operator=(const MPIProcessFactory&);
public:
const std::string& RegisterMPIProcess(const std::string& key, calcFunc* ptr);
void calculate(unsigned int key_pos, unsigned int bufsz, const char* buf, std::deque<std::pair<unsigned int, const char*> >&, boost::mutex&);
unsigned int getKeyPos(const std::string& key);
boost::condition_variable& getConditionVar() { return cv; }
static MPIProcessFactory& getFactory(){static MPIProcessFactory f; return f;}
private:
std::map<const std::string, calcFunc*> calc_map;
//! This condition variable is set when a calculate finishes (but it's up to the user to do so!)
boost::condition_variable cv;
};
}
#endif /* MPIPROCESSFACTORY_H */