Multithreading

AngelScript supports multithreading, though not yet on all platforms. You can determine if multithreading is supported on your platform by calling the asGetLibraryOptions function and checking the returned string for "AS_NO_THREADS". If the identifier is in the returned string then multithreading is not supported.

Even if you don't want or can't use multithreading, you can still write applications that execute multiple scripts simultaneously.

Things to think about with a multithreaded environment

Fibers

AngelScript can be used with fibers as well. However, as fibers are not real threads you need to be careful if multiple fibers need to execute scripts. AngelScript keeps track of active contexts by pushing and popping the context pointers on a stack. With fibers you can easily corrupt this stack if you do not pay attention to where and when script executions are performed.

Try to avoid switching fibers when a script is executing, instead you should suspend the current script execution and only switch to the other fiber when the context's Execute() method returns. If you really must switch fibers while executing a script, then make sure the second fiber initiates and concludes its own script execution before switching back to the original fiber.


Generated on Wed Dec 16 19:34:50 2009 for AngelScript by  doxygen 1.5.9