acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
task_keep.h
1
// Created by camilo on 2022-06-09 14:31 BRT <3ThomasBorregaardSorensen!! and Mummi and bilbo!!
2
#pragma once
3
4
5
#include "acme/platform/keep.h"
6
7
8
#define __keep_current_thread(...) auto COUNTER_TOKEN(__keep_current_thread) = keep(__VA_ARGS__, ::get_task())
9
10
11
template
< >
12
inline ::task* default_keep_value < ::task* >()
13
{
14
15
return ::get_task();
16
17
}
18
19
#define __task_guard_ret(flag, ret) \
20
\
21
synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX); \
22
\
23
if (flag) \
24
{ \
25
\
26
ret; \
27
\
28
} \
29
\
30
auto COUNTER_TOKEN(__task_guard_task_ret) = keep(flag); \
31
\
32
synchronouslock.unlock()
33
34
#define __task_guard(flag) __task_guard_ret(flag, return)
35
36
37
#define __guard_wait_ret(flag, ret) \
38
\
39
synchronous_lock synchronouslock(this->synchronization(), DEFAULT_SYNCHRONOUS_LOCK_SUFFIX); \
40
\
41
while (flag) \
42
{ \
43
\
44
\
45
synchronouslock.unlock(); \
46
\
47
if (!task_sleep(100_ms)) \
48
{\
49
\
50
ret; \
51
\
52
} \
53
\
54
synchronouslock.lock(); \
55
\
56
\
57
} \
58
\
59
auto COUNTER_TOKEN(__guard_wait_ret) = keep(&flag); \
60
\
61
synchronouslock.unlock()
62
63
#define __guard_wait(flag) __task_guard_ret(flag, return)
64
65
parallelization
task_keep.h
Generated by
1.17.0