I just finished my current project, so I have just been looking back at how I used things like AngelScript, and thinking about what might be a better approach for other projects.
My engine was single threaded. During each pass through the engine''s update loop, I would ExecuteStep on each script that was running. That made it so each script essentially ran concurrently. I actually called ExecuteStep on each script a bunch of times during each pass, just so it would speed up their execution.
My question is, how does everyone else deal with integrating AngelScript with their project?
I was thinking about how multithreading with AS might work. I''m sure that I would need to protect the call to asIScriptEngine::CreateContext with some form of critical section, but can two contexts be running in seperate threads without crashing AS?
In my project I have no need for concurrent scripts as they are not attached to individual game objects. As such my script usage is rather basic - during initialisation the script registers what callbacks it wants to receive (input, timers, etc...), and then on those events the registered script function is called.
Angelscript is all over our game............Xtreeme Forces. its heavoly used and to just name a few, the AI file right now is 5000 lines of AS Code. my only issue is its so tightly integrated with our game, i have to literally struggle to update every new version to make sure everything works perfectly fine!
Jayanth.K Raptor Entertainment Pvt. Ltd. http://www.raptorentertainment.com
Angelscript will probably not work very well in multiple threads. I know for sure that asGetActiveContext() will present problems, as it is not thread aware. This doesn''t prevent you for using threads for other tasks.
I''ll correct this behaviour for a future version though.
__________________________________________________________ www.AngelCode.com - game development and more... AngelScript - free scripting library - Tower - free puzzle game