PDA

View Full Version : Does FG spawn additional processing threads?



Minty23185Fresh
July 16th, 2016, 16:52
Is some functionality handled using multiple processing threads? For example dice throws or OOB messaging?

It might introduce a bit of asynchronicity. There’s not too much I can do about it but it would be nice to be aware that the possibility exists.

In the extension I am working on, I swear two messages showed up in the chat in the wrong order. It happened only once and I might be dreaming, but, I thought I observed it. One message was delivered just via Comm, the other through OOB then Comm.

Trenloe
July 16th, 2016, 17:06
Actions (dice rolling) is done asynchronously - there is code before the roll is made (to put it all together) and it is only once the roll has completed that the result of the roll is processed. See the action flow as described at the top of the CoreRPG scripts\manager_actions.lua file.

There are also various events that fire and can trigger code attached to those events.

There's not really multiple thread processing (i.e. more than one set of code processing at exactly the same time), but events interrupt code that is already processing, run some code, then continue with the original code. See "Event Functions" and "Handler Functions" at the bottom of this page: https://www.fantasygrounds.com/modguide/scripting.xcp

Ken L
July 17th, 2016, 11:14
IIRC, Fantasy Grounds is single threaded, including its events (as opposed to JS's single threadedness). Hence why LOD freezes up FG rather than running in the background.