Waiting for coroutines to complete before releasing caller script context

Started by
1 comment, last by WitchLord 4 years, 10 months ago

I have some questions regarding the coroutines addon. I've got a script console, and if i execute a script in it that creates a coroutine, I want to wait until the coroutine is done running before I release the script context, but I do not see how to do that. It seems the 'thread' information exists only inside CContextMgr, and I have no way of figuring out if the main script context spawned new script contexts, and which if any those are. I was thinking I could just create new contexts, and have CContextMgr release them automatically (keepCtx = false), but then I cannot Release the script function that contains the running code. Is there any way to accomplish this without writing my own coroutine system?

Advertisement

The add-on CContextMgr that comes with the SDK is in no way feature complete, as is the case with most of the add-ons. I focus my energy on making the core library as complete as possible, the add-ons are mostly included to help teach application developers on how the library can be used to accomplish whatever it is that the application needs.

I recommend that you customize the add-on to add the features you need for your application. 

You could easily add a method to CContextMgr to query if there are active co-routines related to a context. Simply have the method iterate over the m_threads and then check if the SContextInfo related to your context has any entries in coRoutines. For this to work your application should add the main context with the flag keepCtxAfterExecution so the context pointer can be used as key in the query.

 

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement