forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActiveMethod.cpp
More file actions
58 lines (45 loc) · 1006 Bytes
/
Copy pathActiveMethod.cpp
File metadata and controls
58 lines (45 loc) · 1006 Bytes
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
//
// ActiveMethod.cpp
//
// $Id: //poco/1.4/Foundation/samples/ActiveMethod/src/ActiveMethod.cpp#1 $
//
// This sample demonstrates the ActiveMethod and ActiveResult classes.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/ActiveMethod.h"
#include "Poco/ActiveResult.h"
#include <iostream>
using Poco::ActiveMethod;
using Poco::ActiveResult;
class ActiveMethodExample
{
public:
struct AddArgs
{
int a;
int b;
};
ActiveMethodExample():
activeAdd(this, &ActiveMethodExample::activeAddImp)
{
}
ActiveMethod<int, AddArgs, ActiveMethodExample> activeAdd;
private:
int activeAddImp(const AddArgs& args)
{
return args.a + args.b;
}
};
int main(int argc, char** argv)
{
ActiveMethodExample example;
ActiveMethodExample::AddArgs args = {1, 2};
ActiveResult<int> result = example.activeAdd(args);
result.wait();
std::cout << result.data() << std::endl;
return 0;
}