ArkScript
A small, fast, functional and scripting language for video games
Future.hpp
Go to the documentation of this file.
1
/**
2
* @file Future.hpp
3
* @author Alexandre Plateau (
[email protected]
)
4
* @brief
5
* @version 0.1
6
* @date 2022-05-28
7
*
8
* @copyright Copyright (c) 2022-2024
9
*
10
*/
11
12
#ifndef ARK_VM_FUTURE_HPP
13
#define ARK_VM_FUTURE_HPP
14
15
#include <future>
16
#include <vector>
17
18
#include <
Ark/VM/Value.hpp
>
19
#include <
Ark/VM/ExecutionContext.hpp
>
20
21
namespace
Ark::internal
22
{
23
class
Future
24
{
25
public
:
26
/**
27
* @brief Create a Future and immediately start it through std::async
28
* @param context a dedicated context for the future to run on
29
* @param vm non owning pointer to the VM
30
* @param args list of (function, arguments...) to create the future
31
*/
32
Future
(
ExecutionContext
* context,
VM
* vm, std::vector<Value>& args);
33
34
/**
35
* @brief Await the future, blocking the thread it is ran on
36
* @return Value Nil if the future is invalid (has already been awaited), otherwise the value
37
*/
38
Value
resolve
();
39
40
private
:
41
ExecutionContext
*
m_context
;
42
VM
*
m_vm
;
43
std::future<Value>
m_value
;
///< The actual thread
44
};
45
}
46
47
#endif
ExecutionContext.hpp
Keeping track of the internal data needed by the VM.
Value.hpp
Ark::VM
The ArkScript virtual machine, executing ArkScript bytecode.
Definition
VM.hpp:44
Ark::Value
Definition
Value.hpp:60
Ark::internal::Future
Definition
Future.hpp:24
Ark::internal::Future::m_context
ExecutionContext * m_context
Definition
Future.hpp:41
Ark::internal::Future::m_value
std::future< Value > m_value
The actual thread.
Definition
Future.hpp:43
Ark::internal::Future::m_vm
VM * m_vm
Definition
Future.hpp:42
Ark::internal::Future::resolve
Value resolve()
Await the future, blocking the thread it is ran on.
Definition
Future.cpp:13
Ark::internal::Future::Future
Future(ExecutionContext *context, VM *vm, std::vector< Value > &args)
Create a Future and immediately start it through std::async.
Definition
Future.cpp:7
Ark::internal
Definition
Builtins.hpp:26
Ark::internal::ExecutionContext
Definition
ExecutionContext.hpp:31
include
Ark
VM
Future.hpp
Generated on Wed Jan 15 2025 19:51:44 for ArkScript by
1.12.0