forked from data61/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShareThread.h
75 lines (56 loc) · 1.57 KB
/
ShareThread.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* MalicousRepParty.h
*
*/
#ifndef GC_SHARETHREAD_H_
#define GC_SHARETHREAD_H_
#include "Thread.h"
#include "Processor/Data_Files.h"
#include <array>
namespace GC
{
template<class T>
class ShareThread
{
static thread_local ShareThread<T>* singleton;
public:
static ShareThread& s();
Player* P;
typename T::MC* MC;
typename T::Protocol* protocol;
Preprocessing<T>& DataF;
ShareThread(Preprocessing<T>& prep);
ShareThread(Preprocessing<T>& prep, Player& P,
typename T::mac_key_type mac_key);
virtual ~ShareThread();
virtual typename T::MC* new_mc(typename T::mac_key_type mac_key)
{ return T::new_mc(mac_key); }
void pre_run(Player& P, typename T::mac_key_type mac_key);
void post_run();
void check();
void and_(Processor<T>& processor, const vector<int>& args, bool repeat);
void andrsvec(Processor<T>& processor, const vector<int>& args);
void xors(Processor<T>& processor, const vector<int>& args);
};
template<class T>
class StandaloneShareThread : public ShareThread<T>, public Thread<T>
{
public:
DataPositions usage;
StandaloneShareThread(int i, ThreadMaster<T>& master);
~StandaloneShareThread();
void pre_run();
void post_run() { ShareThread<T>::post_run(); }
};
template<class T>
thread_local ShareThread<T>* ShareThread<T>::singleton = 0;
template<class T>
inline ShareThread<T>& ShareThread<T>::s()
{
if (singleton and T::is_real)
return *singleton;
else
throw runtime_error("no singleton");
}
} /* namespace GC */
#endif /* GC_SHARETHREAD_H_ */