Asynchronous and multi-threaded programming in MQL - page 40

 
Алексей Тарабанов:

Two, or twenty-two threads can be either synchronous or asynchronous. One thread can include both synchronous and asynchronous operations. You have indicated how. Parallel does not know how to include parallel ones.

Well, yes. You can't include parallel calculations in one thread. Synchronous and asynchronous operations can be performed in one or more threads. Only, single-threaded asynchrony is essentially an optimized sequence of operations that is inferior in stability to multi-threaded asynchrony. If one thread fails, the system will continue operating and operations of the stopped process can be dissociated into other threads preserving serviceability. If there is only one thread, the system is kaput when it fails).

Random division by zero in one thread and that's it.
 

Example: there is a synchronous function running in thread 1 and waiting for data from threads 2, 3 and 4, while functions distributed in threads 5, 6, 7 and 8 are waiting for results.

All stand and wait for result. Now, pay attention: what if the synchronous function is waiting for data from its thread? And, God forbid, this data depends on its result?

 
Реter Konow:

Random division by zero in one thread and that's it.

No, that's not all.

 
Алексей Тарабанов:

Example: there is a synchronous function running in thread 1 and waiting for data from threads 2, 3 and 4, while functions distributed in threads 5, 6, 7 and 8 are waiting for results.

All stand and wait for result. Now, pay attention: what if the synchronous function is waiting for data from its thread? And God forbid, this data depends on its result?

Ok, I'll answer it myself:

Canvas will start blinking.

 
Koldun Zloy:

I will translate what you have already been told by a representative of the MT development company:

You cannot create threads from MQL. Not even with WinAPI.

You can do this only by writing your own DLL.


You can, MQL5\Include\WinAPI\processthreadsapi.mqh has a wrapper
HANDLE CreateThread(PVOID thread_attributes,ulong stack_size,PVOID start_address,PVOID parameter,uint creation_flags,uint &thread_id);

But what to do with the tracks through MQL? That's why they wrote that we have to create a DLL and work with them there.


 

Alexei Tarabanov:

Example: there is a synchronous function running in thread 1 and waiting for data from threads 2, 3 and 4, while functions distributed in threads 5, 6, 7 and 8 are waiting for results.

All stand and wait for result. Now, pay attention: what if the synchronous function is waiting for data from its thread? And God forbid, this data depends on its result?

Alexei Tarabanov:

Ok, I'll answer it myself:

Canvas will start blinking.

Highlighted has no meaning.

About the other tracks, until the data is ready, will wait. Nothing will blink.

Reason: