added task_dock

This commit is contained in:
gnembon committed 2020-05-10 17:24:35 -03:00
1 parent 56f8f17aaa
commit 52cf599375
6 files changed
+44 -64

No files matched your search

+12
View File
@@ -790,6 +790,18 @@ Returns true if task has completed, or false otherwise.
Evaluates `expression` synchronized with respect to the lock `lock`. Returns the value of the expression.
### `task_dock(expr)`
In a not-task (running regular code on the main game thread) it is a pass-through command. In tasks - it docks
the current thread on the main server thread and executes expression as one server offline server task.
This is especially helpful in case a task has several docking operations to perform, such as setting a block, and
it would be much more efficient to do them all at once rather then packing each block access in each own call.
Be mindful, that docking the task means that the tick execution will be delayed until the expression is evaluated.
This will synchronize your task with other tasks using `task_dock`, but if you should be using `synchronize` to
synchronize tasks without locking the main thread.
* * *
## Auxiliary functions
+12
View File
@@ -147,6 +147,18 @@ Returns true if task has completed, or false otherwise.
Evaluates `expression` synchronized with respect to the lock `lock`. Returns the value of the expression.
### `task_dock(expr)`
In a not-task (running regular code on the main game thread) it is a pass-through command. In tasks - it docks
the current thread on the main server thread and executes expression as one server offline server task.
This is especially helpful in case a task has several docking operations to perform, such as setting a block, and
it would be much more efficient to do them all at once rather then packing each block access in each own call.
Be mindful, that docking the task means that the tick execution will be delayed until the expression is evaluated.
This will synchronize your task with other tasks using `task_dock`, but if you should be using `synchronize` to
synchronize tasks without locking the main thread.
* * *
## Auxiliary functions
@@ -85,6 +85,7 @@ tanh
task
task_completed
task_count
task_dock
task_join
task_value
throw
@@ -36,7 +36,7 @@
print return exit throw try
task task_count task_value task_join task_completed synchronize
task task_count task_value task_join task_completed synchronize task_dock
system_variable_get system_variable_set