Jump to content
  • Advertisement
FredrikAleksander

Waiting for coroutines to complete before releasing caller script context

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!