Is Access to Global Variables Thread-Safe?

Back to topics list To post a new topic, please log in or register
avatar
47
Simha 2015.02.08 14:36
 

Hello,

 

Terminal global variables are available for concurrent access from all running EAs. Each EA runs on its own thread (as stated on official documentation).

Is access (Read/Write) to global variables assured to be race-condition-free?

 

More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?

 

Thanks much. 

avatar
12992
WHRoeder 2015.02.08 16:11 #
 
Simha:
Is access (Read/Write) to global variables assured to be race-condition-free?
More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.
avatar
2017
gooly 2015.02.08 16:11 #
 

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second.





avatar
47
Simha 2015.02.08 16:42 #
 
WHRoeder:
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.

Thanks for the useful answer.

avatar
47
Simha 2015.02.08 16:43 #
 
gooly:

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second. 

Thanks. I've found this useful.

Back to topics list  

To add comments, please log in or register