-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreducers.h
46 lines (37 loc) · 1.05 KB
/
reducers.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
#ifndef REDUCERS_H
#define REDUCERS_H
#include <pthread.h>
/*
------ REDUCERS NAMESPACE ------
Contains:
- the reducerArg_t struct
- different reducer functions:
-> one for perfect numbers
-> TODO (BONUS)
*/
namespace reducers {
/*
Template reducer struct in order
to achieve a general Map-Reduce.
*/
template <typename T> struct reducerArg_t {
// reducer id
unsigned int rId;
/*
Barrier shared between
all threads (mappers and reducers).
*/
pthread_barrier_t *reducerBarrier;
T *fromMappers;
// constructor
reducerArg_t(unsigned int id = 0, pthread_barrier_t *barrier = NULL, T *fromM = NULL) :
rId(id), reducerBarrier(barrier), fromMappers(fromM) {}
};
/*
Specific reducer thread function used for
collecting the perfect numbers of the respective thread
after the mappers parsed the input files.
*/
void *reducerPerfectNumber(void *arg);
}
#endif