clarify readme

master
Daniel Kolesa 2018-04-28 22:25:03 +02:00
parent 8805594bc2
commit a36144ead6
1 changed files with 10 additions and 18 deletions

View File

@ -54,27 +54,19 @@ project is a part of the larger OctaForge umbrella.
## Threads and coroutines ## Threads and coroutines
*(I've just begun working on this, so many things do not apply yet)* *(In progress)*
Libcubescript aims to provide a degree of thread safety by introducing a concept Libcubescript supports integration with coroutines and threads by providing a
of threads itself. A `CsState` essentially represents a thread - it contains a concept of threads itself. You can create a thread (child state) using the
pointer to CubeScript global state plus any sort of local state and a call/alias main state and it will share global data with the main state, but it also
stack. The main thread (i.e. the state created without any arguments) also owns has its own call stack.
the globals; child states (threads) merely point to them.
Thus, by creating a child state (thread) you get access to all globals (which The "global" state is thread safe, allowing concurrent access from multiple
is thread safe in the implementation) but you also get your own call/alias stack, threads. The "local" state can be yielded as a part of the coroutine without
error buffer and other things that would otherwise be unsafe to access. Thus, affecting any other threads.
if you need to call into a single CubeScript from multiple threads, you simply
create a main state within your main program thread and a child state per each
spawned thread you want to use CubeScript from. Since they're isolated, there
is no problem - and libcubescript can remain almost entirely lockless.
Coroutines are a related concept in this case. We will reuse CubeScript threads This functionality is not exposed into the language itself, but it can be
for them - merely extending them with a way to save the current execution state utilized in the outside native code.
and restore it later. The language itself (or rather, its standard library) will
be extended with new commands to resume and yield coroutines, as well as the
appropriate type extensions.
## Building and usage ## Building and usage