Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Indivisibility of function's calls of a plug-in  (Read 3630 times)

0 Members and 1 Guest are viewing this topic.

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Indivisibility of function's calls of a plug-in
« on: August 07, 2010, 11:38:23 AM »

Hi,
I'm wondering whether calling of a function/method of a plug-in from a script is indivisible or not.
Maybe it will be better if I show you an example. :)

Let's suppose there are a method A and a method B in a plug-in.
The methods share a data set (for example two variables).
The method A modifies the data set and the method B reads that data set.
The method A is called in a game main loop and the method B is called when a LeftClick event is trigged.

And now suppose this situation:
The loop has got in the method A and the method has started doing its job.
However, a LeftClick event is trigged during its job.
So, the method B should be called.

I need to have guaranteed that the method B won't be called until the method A has finished its job.

Does WME guaranteed that thing?

I haven't found that information in the documentation but I think it's an important information for developing a plug-in.


I hope I've explained the problem in the understandable way.

Thanks for replies :)
« Last Edit: August 07, 2010, 11:41:32 AM by Mihulik »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Indivisibility of function's calls of a plug-in
« Reply #1 on: August 08, 2010, 12:53:28 AM »

I am not sure I understand but both plugin methods are called from the WME script, no?

Then the easiest way is to have a variable which will be set to true when you enter method A and back to false when you leave it. This way when you need to enter method B you first wait for end of method A and then you call method B. Or am I missing something?
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Indivisibility of function's calls of a plug-in
« Reply #2 on: August 08, 2010, 07:59:21 AM »

I am not sure I understand but both plugin methods are called from the WME script, no?
Yeah, both methods are called from a script.
Then the easiest way is to have a variable which will be set to true when you enter method A and back to false when you leave it. This way when you need to enter method B you first wait for end of method A and then you call method B. Or am I missing something?
It's an easy and sufficient solution. However, if the engine guarantees that calling of a function is indivisible, then that's needless.

I just think it's an important information when somebody needs to develop a plug-in. :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Indivisibility of function's calls of a plug-in
« Reply #3 on: August 09, 2010, 10:11:51 AM »

Everything in WME runs in a single thread, so your plugin method has to finish, before the control is given back to WME. This means it's not possible for two functions to run simultaneously.
If one needs to do some long running action, the plugin method only starts the action (and returns), and the action is then processed in the update event(s).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Mihulik

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 71
    • View Profile
Re: Indivisibility of function's calls of a plug-in
« Reply #4 on: August 09, 2010, 10:46:58 AM »

Everything in WME runs in a single thread, so your plugin method has to finish, before the control is given back to WME. This means it's not possible for two functions to run simultaneously.
Great. It's exactly the information I need. :)
Thanks!
If one needs to do some long running action, the plugin method only starts the action (and returns), and the action is then processed in the update event(s).
Yes. However, I don't need to do a long running action. I just need to have guaranteed that two methods can't run together. :)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Indivisibility of function's calls of a plug-in
« Reply #5 on: August 09, 2010, 10:58:56 AM »

I can guarantee that :)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.037 seconds with 24 queries.