Initial release commit
This commit is contained in:
48
include/lua_parallel.h
Normal file
48
include/lua_parallel.h
Normal file
@@ -0,0 +1,48 @@
|
||||
// A lua module that provides multithreadding utilities to lua
|
||||
#pragma once
|
||||
#include "lua_stack.h"
|
||||
|
||||
// All functions are sandboxed
|
||||
int luaopen_parallel_safe(lua_State* L);
|
||||
// Some functions are not sandboxed
|
||||
int luaopen_parallel_unsafe(lua_State* L);
|
||||
|
||||
int lua_parallel_create_mutex(lua_State* L);
|
||||
int lua_parallel_destroy_mutex(lua_State* L);
|
||||
int lua_parallel_lock_mutex(lua_State* L);
|
||||
int lua_parallel_unlock_mutex(lua_State* L);
|
||||
|
||||
int lua_parallel_create_promise(lua_State* L);
|
||||
int lua_parallel_destroy_promise(lua_State* L);
|
||||
int lua_parallel_await_promise(lua_State* L);
|
||||
int lua_parallel_fullfilled_promise(lua_State* L);
|
||||
int lua_parallel_fullfilled_all_promises(lua_State* L);
|
||||
|
||||
struct lua_parallel_thread
|
||||
{
|
||||
// A list of all messages recieved from other threads
|
||||
lua_stack stack;
|
||||
// Coroutine lua state pointer
|
||||
lua_State* L;
|
||||
// underlying thread object
|
||||
std::jthread thread;
|
||||
};
|
||||
|
||||
// userdata<thread> function parallel.create_thread(function fn, ...)
|
||||
int lua_parallel_create_thread(lua_State* L);
|
||||
// N/A
|
||||
int lua_parallel_destroy_thread(lua_State* L);
|
||||
// nil function parallel.join(userdata<thread> thread)
|
||||
int lua_parallel_join_thread(lua_State* L);
|
||||
// nil function parallel.request_stop(userdata<thread> thread)
|
||||
int lua_parallel_request_stop(lua_State* L);
|
||||
// boolean function parallel.stop_requested()
|
||||
int lua_parallel_stop_requested(lua_State* L);
|
||||
// nil function parallel.sendmsg(userdata<thread> thread, ...)
|
||||
int lua_parallel_sendmsg_thread(lua_State* L);
|
||||
// table function parallel.recvmsg(userdata<thread>[] | nil filter)
|
||||
int lua_parallel_recvmsg_thread(lua_State* L);
|
||||
// number function parallel.recvsize(userdata<thread>[] | nil filter)
|
||||
int lua_parallel_recvsize_thread(lua_State* L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user