From 7d29a7ebe9dc504eec5e55121df2bf55503df26b Mon Sep 17 00:00:00 2001 From: Ding Li Date: Fri, 26 May 2017 13:14:21 +0800 Subject: [PATCH] update documentation --- README.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1c2582a..679f438 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,23 @@ This binding contains three sets of files: MQL strings are Win32 UNICODE strings (basically 2-byte UTF-16). In this binding all strings are converted to utf-8 strings before sending to the dll layer. The ZmqMsg supports a constructor from MQL strings, the default is _NOT_ null-terminated. +## Notes on context creation + +In the official guide: + +> You should create and use exactly one context in your process. Technically, +> the context is the container for all sockets in a single process, and acts as +> the transport for inproc sockets, which are the fastest way to connect threads +> in one process. If at runtime a process has two contexts, these are like +> separate ZeroMQ instances. + +In MetaTrader, every Script and Expert Advsior has its own thread, but they all +share a process, that is the Terminal. So it is advised to use a single global +context on all your MQL programs. The `shared` parameter of `Context` is used +for sychronization of context creation and destruction. It is better named +globally, and in a manner not easily recognized by humans, for example: +"__3kewducdxhkd__" + ## Usage You can find a simple test script in `Scripts/Test`, and you can find examples of the official guide in Scripts/ZeroMQGuideExamples. I intend to translate all examples to this binding, but now only the hello world example is provided. I will gradually add those examples. Of course forking this binding if you are interested and welcome to send pull requests. @@ -42,7 +59,7 @@ Here is a sample from `HelloWorldServer.mq4`: //+------------------------------------------------------------------+ void OnStart() { - Context context; + Context context("helloworld"); Socket socket(context,ZMQ_REP); socket.bind("tcp://*:5555"); @@ -74,5 +91,5 @@ void OnStart() 2. Add more examples from the official ZMQ guide. ## Changes - -2016-12-27: Released 1.0. \ No newline at end of file +2017-05-26: Released 1.1: add the ability to share a ZMQ context globally in a terminal +2016-12-27: Released 1.0.