ArkScript
A small, fast, functional and scripting language for video games
Future.cpp
Go to the documentation of this file.
1#include <Ark/VM/Future.hpp>
2
3#include <Ark/VM/VM.hpp>
4
5namespace Ark::internal
6{
7 Future::Future(ExecutionContext* context, VM* vm, std::vector<Value>& args) :
8 m_context(context), m_vm(vm)
9 {
10 m_value = std::async(std::launch::async, [vm, context, args]() mutable {
11 return vm->resolve(context, args);
12 });
13 }
14
16 {
17 m_value.wait();
18 Value res = m_value.get();
19
21 m_context = nullptr;
22
23 return res;
24 }
25}
The ArkScript virtual machine.
The ArkScript virtual machine, executing ArkScript bytecode.
Definition: VM.hpp:48
void deleteContext(internal::ExecutionContext *ec)
Free a given execution context.
Definition: VM.cpp:203
Value resolve(const Value *val, Args &&... args)
Resolving a function call (called by plugins and builtins)
ExecutionContext * m_context
Definition: Future.hpp:31
std::future< Value > m_value
Definition: Future.hpp:33
Future(ExecutionContext *context, VM *vm, std::vector< Value > &args)
Definition: Future.cpp:7