acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
task_flag.h
1// Created by camilo on 2022-06-09 11:32 BRT <3ThomasBorregaardSorensen!! Mummi and bilbo!!
2#pragma once
3
4
5#include "acme/prototype/prototype/enum_bitset.h"
6
7
8using task_bitset = enum_bitset < enum_task_flag, e_task_flag_count >;
9
10
11CLASS_DECL_ACME task_bitset& task_flag();
12
13
14class CLASS_DECL_ACME ___keep_task_flag
15{
16public:
17
18
19 enum_task_flag m_eflag;
20 bool m_bSet;
21
22
23 ___keep_task_flag(enum_task_flag eflag) :
24 m_eflag(eflag),
25 m_bSet(task_flag().is_set(eflag))
26 {
27
28
29 }
30
31
32 ~___keep_task_flag()
33 {
34
35 task_flag().set(m_eflag, m_bSet);
36
37 }
38
39
40};
41
42
43inline ___keep_task_flag keep_task_flag(enum_task_flag eflag)
44{
45
46 return eflag;
47
48}
49
50
51
52#define __keep_task_flag(...) auto COUNTER_TOKEN(__keep_task_flag) = keep_task_flag(__VA_ARGS__)
53
54
55
56
57
58#define __task_guard_ret(flag, ret) \
59 \
60synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX); \
61 \
62if (flag) \
63{ \
64\
65 ret; \
66\
67} \
68\
69auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
70\
71synchronouslock.unlock()
72
73#define __task_guard(flag) __task_guard_ret(flag, return)
74
75
76#define __prevent_bad_status_exception __keep_task_flag(e_task_flag_prevent_bad_status_exception)
77
78
79
Definition task_flag.h:15