ArkScript
A small, lisp-inspired, functional scripting language
Future.hpp
Go to the documentation of this file.
1
/**
2
* @file Future.hpp
3
* @author Lex Plateau (lexplt.dev@gmail.com)
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
21
{
22
class
VM
;
23
}
24
25
namespace
Ark::internal
26
{
27
class
Future
28
{
29
public
:
30
/**
31
* @brief Create a Future and immediately start it through std::async
32
* @param context a dedicated context for the future to run on
33
* @param vm non owning pointer to the VM
34
* @param args list of (function, arguments...) to create the future
35
*/
36
Future
(
ExecutionContext
* context,
VM
* vm, std::vector<Value>& args);
37
38
/**
39
* @brief Await the future, blocking the thread it is run on
40
* @return Value Nil if the future is invalid (has already been awaited), otherwise the value
41
*/
42
Value
resolve
();
43
44
static
UserType::ControlFuncs
ControlFunctions
;
45
46
private
:
47
std::future<Value>
m_value
;
///< The actual thread
48
VM
*
m_vm
;
///< Non-owning pointer
49
50
void
deleteSelfViaVM
();
51
};
52
}
53
54
#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:46
Ark::Value
Definition
Value.hpp:91
Ark::internal::Future
Definition
Future.hpp:28
Ark::internal::Future::m_value
std::future< Value > m_value
The actual thread.
Definition
Future.hpp:47
Ark::internal::Future::m_vm
VM * m_vm
Non-owning pointer.
Definition
Future.hpp:48
Ark::internal::Future::deleteSelfViaVM
void deleteSelfViaVM()
Definition
Future.cpp:47
Ark::internal::Future::ControlFunctions
static UserType::ControlFuncs ControlFunctions
Definition
Future.hpp:44
Ark::internal::Future::resolve
Value resolve()
Await the future, blocking the thread it is run on.
Definition
Future.cpp:37
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:20
Ark::internal
Definition
Builtins.hpp:26
Ark::internal::ErrorKind::VM
@ VM
Ark
Definition
Builtins.hpp:19
Ark::UserType::ControlFuncs
A structure holding a bunch of pointers to different useful functions related to this usertype.
Definition
UserType.hpp:55
Ark::internal::ExecutionContext
Definition
ExecutionContext.hpp:27
include
Ark
VM
Future.hpp
Generated on Sun Sep 28 2025 15:55:36 for ArkScript by
1.12.0