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 Internal object to resolve asynchronously a function call in ArkScript
5
* @date 2022-05-28
6
*
7
* @copyright Copyright (c) 2022-2025
8
*
9
*/
10
11
#ifndef ARK_VM_FUTURE_HPP
12
#define ARK_VM_FUTURE_HPP
13
14
#include <future>
15
#include <vector>
16
17
#include <
Ark/VM/Value.hpp
>
18
#include <
Ark/VM/ExecutionContext.hpp
>
19
20
namespace
Ark::internal
21
{
22
class
Future
23
{
24
public
:
25
/**
26
* @brief Create a Future and immediately start it through std::async
27
* @param context a dedicated context for the future to run on
28
* @param vm non owning pointer to the VM
29
* @param args list of (function, arguments...) to create the future
30
*/
31
Future
(
ExecutionContext
* context,
VM
* vm, std::vector<Value>& args);
32
33
/**
34
* @brief Await the future, blocking the thread it is ran on
35
* @return Value Nil if the future is invalid (has already been awaited), otherwise the value
36
*/
37
Value
resolve
();
38
39
private
:
40
ExecutionContext
*
m_context
;
41
VM
*
m_vm
;
42
std::future<Value>
m_value
;
///< The actual thread
43
};
44
}
45
46
#endif
ExecutionContext.hpp
Keeping track of the internal data needed by the VM.
Value.hpp
Default value type handled by the virtual machine.
Ark::VM
The ArkScript virtual machine, executing ArkScript bytecode.
Definition
VM.hpp:45
Ark::Value
Definition
Value.hpp:59
Ark::internal::Future
Definition
Future.hpp:23
Ark::internal::Future::m_context
ExecutionContext * m_context
Definition
Future.hpp:40
Ark::internal::Future::m_value
std::future< Value > m_value
The actual thread.
Definition
Future.hpp:42
Ark::internal::Future::m_vm
VM * m_vm
Definition
Future.hpp:41
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:25
Ark::internal::ExecutionContext
Definition
ExecutionContext.hpp:31
include
Ark
VM
Future.hpp
Generated on Wed May 21 2025 18:40:52 for ArkScript by
1.12.0