Fixed a few bugs in spread order management.

This commit is contained in:
Pedro Pinto committed 2017-10-05 13:21:54 +00:00
1 parent bd3b433ec4
commit 8602fde89b
3 files changed
+12 -5

No files matched your search

@@ -17,9 +17,12 @@ public:
void on(event::MDSubscription const&sub)
{
auto k = sub.for_security->id();
for (auto &h : _handles)
if (h.handle->key() == k)
if (h.handle->key() == k) {
h.last = utils::TimeStamp();
return ;
}
auto managed_handle = _md_consumer.get_managed_handle(k);
_keep_alive.push_back(managed_handle);
@@ -52,7 +55,6 @@ private:
md2::MDConsumerHandle* handle;
};
std::vector<HandleRecord> _handles;
md::MDRecoverableConsumer _md_consumer;
std::vector<std::shared_ptr<md2::MDConsumerHandle>> _keep_alive;
@@ -183,6 +183,7 @@ struct FastExecutor {
struct SlowExecutor {
securities::SecurityDB &sec_db;
NativeOrderFactory &native_order_factory;
OrderDB &order_db;
FillDB &fill_db;
SlowNode node;
@@ -194,8 +195,12 @@ struct SlowExecutor {
std::atomic<bool> done;
std::thread worker;
SlowExecutor(securities::SecurityDB &db,OrderDB &order_db,FillDB &fill_db)
SlowExecutor(securities::SecurityDB &db,
NativeOrderFactory &native_order_factory,
OrderDB &order_db,
FillDB &fill_db)
: sec_db(db),
native_order_factory(native_order_factory),
order_db(order_db),
fill_db(fill_db),
node(),
@@ -235,6 +240,7 @@ struct SlowExecutor {
while (!done) {
sec_db.do_work();
time_source.do_work();
native_order_factory.do_work();
if (!node.do_work())
std::this_thread::sleep_for(10ms);
}
@@ -252,7 +258,7 @@ struct OrderServiceServer::PImpl
order_db(),
fill_db(),
fast(get_connection(),sec_db,native_order_factory,order_db.retrieve_all()),
slow(sec_db,order_db,fill_db),
slow(sec_db,native_order_factory,order_db,fill_db),
state(State::PENDING_INIT),
known_native_orders(),
publish_orders(),
@@ -32,7 +32,6 @@ public:
SpreaderOrderBase(securities::SecurityDB &,
NativeOrderFactory &,
api::orderman::OrderState const&);
SpreaderOrderBase(securities::SecurityDB &,
NativeOrderFactory &,
OrderKey ,