Jump to content
  • Advertisement
Sign in to follow this  
Servant of the Lord

RequestContext() / ReturnContext() question

This topic is 1139 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

On this page, the documentation says:
It is seldom necessary to maintain more than one script context at a time, with the only exceptions being when a script calls an application function that in turn calls another script before returning, and if multiple scripts are running in parallel.
 
Try to avoid associating a unique context with each object that may need to call scripts. Instead keep a shared pool of contexts that can be requested by the objects on a need-to basis.

 

 

It sounds like that's what aslScriptEngine::RequestContext() and aslScriptEngine::ReturnContext() do for me, as convenience functions?
So if I have several scripts I'm wanting to run in parallel (not multithreaded, but with their execution being suspended and resumed at different times with their states needing to be preserved), can I just let AngelScript handle the pool of contexts for me using the two above functions?

Share this post


Link to post
Share on other sites
Advertisement

I'll need to make a clarification on that page in the manual. Thanks for brining this up.

 

RequestContext and ReturnContext does not implement the context pool for you. However, they are there to simplify the implementation of a context pool. By default, these methods internally calls CreateContext and Release, but if you register the context callbacks they will call those instead of CreateContext/Release. Registering the context callbacks will allow the application to prepare the context for the engine's internal calls too, thus allowing the application to trace/debug even these internal calls (internal calls happens for example when initializing global variables or destroying objects from the garbage collector). The add-ons are also using the RequestContext and ReturnContext calls so all goes to the same place.

 

A basic implementation of a context pool is described here on the fine tuning page in the manual.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!