NXC
Version 1.2.1 r5
|
An optional keyword that can be specified prior to the return type of a function is the safecall keyword.
If a function is marked as safecall then the compiler will synchronize the execution of this function across multiple threads by wrapping each call to the function in Acquire and Release calls. If a second thread tries to call a safecall function while another thread is executing it the second thread will have to wait until the function returns to the first thread.
The code example below shows how you can use the safecall keyword to make a function synchronize its execution when it is shared between multiple threads.