Old 06-10-2019, 04:34 PM   #1
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 583
Default JSFX, _global, and concurrency

Suppose I have a JSFX that does this:

Code:
local_variable = _global.foo
_global.foo += 1
These kinds of get-and-set operations are red flags from a concurrency perspective, but I don't understand the thread safety aspects of this code in the context of a JSFX, or even if thread safety is relevant.

If all JSFX are executed from a single thread with no preemption possible, as I believe is the case, then this code is safe. Otherwise, I'm hoping someone can explain to me if it's possible to make it safe (mutexes and the like).

Thanks!
tack is offline   Reply With Quote
Old 06-10-2019, 04:37 PM   #2
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 583
Default

Aha, answered my own question. Just discovered the existence of atomic_add() in EEL.
tack is offline   Reply With Quote
Old 06-10-2019, 09:38 PM   #3
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 7,098
Default

Thanks for reporting back !
-Michael
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.