Jump to content
  • Advertisement
Sign in to follow this  
Friggle

C'tors called during compile

This topic is 3493 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

Hi, I recognized something strange and wanted to find out if this is intended or not: The constructors of global object instances (allocated outside any function) seem to be called during compilation of the script already rather than during an outside call to the Execute method of the script context. This actually causes problems in my application scenario (as described below) and I wanted to ask if this is going to be changed (if possible at all) or if I will have to change my approach. Here's my problem: My application compiles the script(or rather scripts since I now use the ScriptBuilder that allows for #include to be used) from within the main UI thread. If everything works fine then the UI thread starts a worker thread (let's call it 'scripting thread' here) which calls the Execute() method of the script context. There are registered functions that can be performed by the scripting thread on its own, no problems here. However, there are other registered functions that send messages to the UI thread instead which does the actual work. Once the UI thread has finished executing the corresponding function it sets an event the scripting thread is waiting for. Certainly this concept breaks if the UI thread is busy compiling the script and if one of the script classes' C'tors performs a call to such a function already during compilation: The UI thread sends a message to itself and will get stuck while waiting for the event to be set. Certainly I could go and move the compilation to the scripting thread, too. It's just quite a bit of re-work and regression testing I would have to face and I wouldn't do that if my observation is not an intended behaviour... Regards

Share this post


Link to post
Share on other sites
Advertisement
You can call


engine->SetEngineProperty(asEP_INIT_GLOBAL_VARS_AFTER_BUILD, false);


to turn of the automatic initialization of the global variables. When you're ready you have to call


module->ResetGlobalVars();


to perform the initial initialization. If you forget to call ResetGlobalVars() you'll likely end up with null-pointer script exceptions.

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.

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!