Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复processQueryAllTickersFull中task未delete的bug #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// vnctpmd.cpp : ���� DLL Ӧ�ó���ĵ���������
// vnctpmd.cpp : 定义 DLL 应用程序的导出函数。
//
//#include "stdafx.h"
#include "vnxtpquote.h"

///-------------------------------------------------------------------------------------
///��Python����C++����ת���õĺ���
///从Python对象到C++类型转换用的函数
///-------------------------------------------------------------------------------------

void getInt(dict d, string key, int *value)
{
if (d.has_key(key)) //����ֵ����Ƿ���ڸü�ֵ
if (d.has_key(key)) //检查字典中是否存在该键值
{
object o = d[key]; //��ȡ�ü�ֵ
extract<int> x(o); //������ȡ��
if (x.check()) //���������ȡ
object o = d[key]; //获取该键值
extract<int> x(o); //创建提取器
if (x.check()) //如果可以提取
{
*value = x(); //��Ŀ������ָ�븳ֵ
*value = x(); //对目标整数指针赋值
}
}
};
Expand Down Expand Up @@ -43,8 +43,8 @@ void getStr(dict d, string key, char *value)
{
string s = x();
const char *buffer = s.c_str();
//���ַ���ָ�븳ֵ����ʹ��strcpy_s, vs2013ʹ��strcpy����ͨ����
//+1Ӧ������ΪC++�ַ����Ľ�β���ţ������ر�ȷ�����������1�����
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
//+1应该是因为C++字符串的结尾符号?不是特别确定,不加这个1会出错
#ifdef _MSC_VER //WIN32
strcpy_s(value, strlen(buffer) + 1, buffer);
#elif __GNUC__
Expand Down Expand Up @@ -75,7 +75,7 @@ string addEndingChar(char *value){
}

///-------------------------------------------------------------------------------------
///C++�Ļص����������ݱ��浽������
///C++的回调函数将数据保存到队列中
///-------------------------------------------------------------------------------------

void QuoteApi::OnDisconnected(int reason)
Expand Down Expand Up @@ -559,7 +559,7 @@ void QuoteApi::OnUnSubscribeAllOptionTickByTick(XTP_EXCHANGE_TYPE exchage_id, XT
this->task_queue.push(task);
};
///-------------------------------------------------------------------------------------
///�����̴߳Ӷ�����ȡ�����ݣ�ת��Ϊpython����󣬽�������
///工作线程从队列中取出数据,转化为python对象后,进行推送
///-------------------------------------------------------------------------------------

void QuoteApi::processTask()
Expand Down Expand Up @@ -1214,7 +1214,7 @@ void QuoteApi::processQueryAllTickers(Task *task)
{
PyLock lock;

//�ֶ��޸�
//手动修改
dict data;
if (task->task_data)
{
Expand Down Expand Up @@ -1250,7 +1250,7 @@ void QuoteApi::processQueryTickersPriceInfo(Task *task)
{
PyLock lock;

//�ֶ��޸�
//手动修改
dict data;
if (task->task_data)
{
Expand Down Expand Up @@ -1379,7 +1379,7 @@ void QuoteApi::processUnSubscribeAllOptionTickByTick(Task *task)
void QuoteApi::processQueryAllTickersFullInfo(Task* task) {
PyLock lock;

//�ֶ��޸�
//手动修改
dict data;
if (task->task_data)
{
Expand Down Expand Up @@ -1425,11 +1425,13 @@ void QuoteApi::processQueryAllTickersFullInfo(Task* task) {
}

this->onQueryAllTickersFullInfo(data, error, task->task_last);

delete task;
}


///-------------------------------------------------------------------------------------
///��������
///主动函数
///-------------------------------------------------------------------------------------

void QuoteApi::createQuoteApi(int clientid, string path, int log_level)
Expand All @@ -1445,7 +1447,7 @@ void QuoteApi::release()

int QuoteApi::exit()
{
//�ú�����ԭ��API��û�У����ڰ�ȫ�˳�API�ã�ԭ����join�ƺ���̫�ȶ�
//该函数在原生API里没有,用于安全退出API用,原生的join似乎不太稳定
this->api->RegisterSpi(NULL);
this->api->Release();
this->api = NULL;
Expand Down Expand Up @@ -1788,7 +1790,7 @@ int QuoteApi::unSubscribeAllOptionTickByTick(int exchange)
};

///-------------------------------------------------------------------------------------
///Boost.Python��װ
///Boost.Python封装
///-------------------------------------------------------------------------------------

struct QuoteApiWrap : QuoteApi, wrapper < QuoteApi >
Expand Down Expand Up @@ -2110,7 +2112,7 @@ struct QuoteApiWrap : QuoteApi, wrapper < QuoteApi >

BOOST_PYTHON_MODULE(vnxtpquote)
{
PyEval_InitThreads(); //����ʱ���У���֤�ȴ���GIL
PyEval_InitThreads(); //导入时运行,保证先创建GIL

class_<QuoteApiWrap, boost::noncopyable>("QuoteApi")
.def("createQuoteApi", &QuoteApiWrap::createQuoteApi)
Expand Down