Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Plugin / Gideros Studio thread question — Gideros Forum

Plugin / Gideros Studio thread question

gorkemgorkem Maintainer
edited February 2012 in Plugins
This discussion was created from comments split from: Plugin / Gideros Studio thread question.

Original question:


I have a plugin variable called count.
I have a Gideros Studio function setCount that calls a plugin function setCount which sets the plugin variable count to 52

I have another plugin function that

1. sets count to 0
2. calls Gideros Studio setCount which calls the plugin function which changes count to 52
3. uses variable count

Does step 3 wait until the Gideros Studio function has been completed, so that I can rely on the variable count being set by Gideros Studio?

Or can plugin functions happen on a different thread than Gideros Studio functions?

In my tests it appears that the Gideros Studio function and the plugin functions are done on the same thread, so I can rely on it, but I wondered if this is always the case.

Also, is it worth having a separate forum category for plugins, where we can discuss various plugin aspects, as opposed to Gideros Studio code?

Likes: Caroline

+1 -1 (+1 / -0 )Share on Facebook

Comments

  • To answer your first question. I read here on the forum that everything in Gideros runs in a single thread atm.
  • Thanks gorkem and Mike :D.

    I guess I'm going to assume it stays that way.
  • When you call your plugin function in Gideros, it simply depends on how you have coded your plugin. If you didn't use multithreading, then you return the result and Gideros goes on with the lua code. If you dispatch an event, this will be handled at first.

    Gideros is an event based engine. That means it will first run all the code that is runable from your files. Setting up graphics, sounds, datas etc. After that it will start displaying all the content and also process in each frame the event handlers you have set up in your code. Or when an event happens, like a touch or a timer. I don't know in which order Gideros does that exactly. Does it first processes timers, then ENTER_FRAME, or are the executed in their order of assignment? Atilim should be able to answer this. As long as the LUA code of an event handler is processed, only this runs and not another one.
  • atilimatilim Maintainer
    edited February 2012
    Hi,

    Lua code and plugins are always executed on main thread and rendering is done on separate thread. Therefore, @Caroline's code always runs without problem.

    On the other hand, Lua is not thread safe. Therefore, if your create a NSThread and try to call some lua functions on other than main thread, most probably your program will crash. Pooling is usually the best choice here.

    The event execution order is like: touch events are dispatched first, then timer events and then ENTER_FRAME event. But I think it's better to write code that doesn't rely on this order.

    cheers,
  • That's great - so I can treat Gideros Studio functions as just a normal function called from a plugin if I wanted.
    @Caroline's code always runs without problem.
    Lol - I only wish that were true :-t
Sign In or Register to comment.