-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWorkerTask.h
44 lines (32 loc) · 853 Bytes
/
WorkerTask.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
#pragma once
#include <functional>
#include <zmqpp/zmqpp.hpp>
struct WorkerTask
{
struct Guard
{
zmqpp::socket &socket_;
explicit Guard(zmqpp::socket &socket): socket_{socket}
{}
Guard(const Guard &) = delete;
Guard &operator=(const Guard &) = delete;
};
struct MasterGuard: public Guard
{
using Guard::Guard;
~MasterGuard();
};
struct SlaveGuard: public Guard
{
using Guard::Guard;
~SlaveGuard();
};
using Transform = std::function<zmqpp::message (zmqpp::message)>;
Transform transform_;
explicit WorkerTask(Transform transform):
transform_{std::move(transform)}
{}
WorkerTask(const WorkerTask &) = delete;
WorkerTask &operator=(const WorkerTask &) = delete;
void operator()(zmqpp::socket &);
};