From 5f00bbf08c652db6585574a120ce9f2aece105d1 Mon Sep 17 00:00:00 2001 From: Bigtan Date: Fri, 21 Oct 2016 15:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E6=9E=90=E6=9E=84=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简化析构函数 --- vn.ib/vnib/vnib/vnib.h | 57 ++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/vn.ib/vnib/vnib/vnib.h b/vn.ib/vnib/vnib/vnib.h index f316d9eb..c3283e2b 100644 --- a/vn.ib/vnib/vnib/vnib.h +++ b/vn.ib/vnib/vnib/vnib.h @@ -1,21 +1,21 @@ -//˵ +//说明部分 -//ϵͳ +//系统 #include "StdAfx.h" #include //Boost #define BOOST_PYTHON_STATIC_LIB -#include //pythonװ -#include //pythonװ -#include //pythonװ +#include //python封装 +#include //python封装 +#include //python封装 -#include //Pythonװ -#include //Pythonװ +#include //Python封装 +#include //Python封装 -#include //pythonװ -#include //е̹߳ -#include //е̹߳ +#include //python封装 +#include //任务队列的线程功能 +#include //任务队列的线程功能 #include @@ -25,31 +25,31 @@ #include "EClientSocket.h" #include "EReader.h" -//ռ +//命名空间 using namespace std; using namespace boost::python; using namespace boost; ///------------------------------------------------------------------------------------- -///APIеIJ +///API中的部分组件 ///------------------------------------------------------------------------------------- -//GILȫ򻯻ȡã -//ڰC++̻߳GILӶֹpython +//GIL全局锁简化获取用, +//用于帮助C++线程获得GIL锁,从而防止python崩溃 class PyLock { private: PyGILState_STATE gil_state; public: - //ijдöʱGIL + //在某个函数方法中创建该对象时,获得GIL锁 PyLock() { gil_state = PyGILState_Ensure(); }; - //ijɺٸöʱGIL + //在某个函数完成后销毁该对象时,解放GIL锁 ~PyLock() { PyGILState_Release(gil_state); @@ -58,7 +58,7 @@ public: ///------------------------------------------------------------------------------------- -///ǿת +///强制转化相关 ///------------------------------------------------------------------------------------- boost::python::list tagvaluelist_to_pylist(); @@ -66,7 +66,7 @@ boost::python::list tagvaluelist_to_pylist(); TagValueListSPtr pylist_to_tagvaluelist(); ///------------------------------------------------------------------------------------- -/// +///声明类 ///------------------------------------------------------------------------------------- class VnIbApi; @@ -74,7 +74,7 @@ class VnIbApi; class IbWrapper; ///------------------------------------------------------------------------------------- -///C++ SPIĻصʵ +///C++ SPI的回调函数方法实现 ///------------------------------------------------------------------------------------- class IbWrapper : public EWrapper @@ -223,7 +223,7 @@ public: ///------------------------------------------------------------------------------------- -///װAPI +///封装后的API类 ///------------------------------------------------------------------------------------- class VnIbApi @@ -248,24 +248,17 @@ public: ~VnIbApi() { - if (this->client) - { - delete this->client; - } - - if (this->wrapper) - { - delete this->wrapper; - } + delete this->client; + delete this->wrapper; }; //------------------------------------------------------------------------------------- - //checkMessages̹߳ + //负责调用checkMessages的线程工作函数 //------------------------------------------------------------------------------------- void run(); //------------------------------------------------------------------------------------- - //ص + //回调函数 //------------------------------------------------------------------------------------- virtual void nextValidId(OrderId orderId){}; @@ -408,7 +401,7 @@ public: */ //------------------------------------------------------------------------------------- - // + //主动函数 //------------------------------------------------------------------------------------- bool eConnect(string host, int port, int clientId, bool extraAuth);