forked from ComputationalRadiationPhysics/redGrapes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
7_event.cpp
53 lines (39 loc) · 1.4 KB
/
7_event.cpp
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
/* Copyright 2019 Michael Sippel
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_OFF
#include <iostream>
#include <thread>
#include <chrono>
#include <redGrapes/redGrapes.hpp>
#include <redGrapes/task/property/inherit.hpp>
#include <redGrapes/task/property/resource.hpp>
#include <redGrapes/resource/ioresource.hpp>
int main()
{
spdlog::set_level( spdlog::level::trace );
spdlog::set_pattern("[thread %t] %^[%l]%$ %v");
redGrapes::init(1);
redGrapes::Resource< redGrapes::access::IOAccess > r1;
auto event_f = redGrapes::emplace_task(
[] {
std::cout << "Task 1" << std::endl;
return redGrapes::create_event();
}
).resources({ r1.make_access(redGrapes::access::IOAccess::write) }).submit();
redGrapes::emplace_task(
[] {
std::cout << "Task 2" << std::endl;
}
).resources({ r1.make_access(redGrapes::access::IOAccess::write) });
auto event = event_f.get();
std::cout << "Task 1 finished" << std::endl;
std::this_thread::sleep_for( std::chrono::seconds(1) );
std::cout << "notify event" << std::endl;
event->notify();
redGrapes::finalize();
return 0;
}