Spark-496, spark-497. Store and retrieve synthetic securities from a single block of shared memory.
This commit is contained in:
1 parent
8a05326f74
commit
7a2d24cf54
8 files changed
+36
-55
No files matched your search
@@ -59,11 +59,11 @@ struct DatedHandle {
|
||||
};
|
||||
|
||||
struct MDConsumerGroup {
|
||||
MDConsumerGroup(const UserSymbol& symbol, std::shared_ptr<api::ISyntheticSecurityService>& ss) :
|
||||
// probably just have to send the consumer in from outside
|
||||
MDConsumerGroup(const UserSymbol& symbol) :
|
||||
symbol(symbol),
|
||||
synt(ss),
|
||||
platform(platform_for_exchange(symbol.exchange())),
|
||||
consumer(symbol, ss),
|
||||
consumer(symbol, nullptr),
|
||||
channel(consumer.get_channel(symbol)),
|
||||
handles(new tbb::concurrent_vector<DatedHandle>())
|
||||
{
|
||||
@@ -74,7 +74,7 @@ struct MDConsumerGroup {
|
||||
// if hearbeat is ok just return
|
||||
if (consumer.all_heartbeats_ok()) return;
|
||||
// otherwise construct a new MDConsumer
|
||||
MDConsumer temp(symbol, synt);
|
||||
MDConsumer temp(symbol, nullptr);
|
||||
if (temp.all_heartbeats_ok()) {
|
||||
consumer.swap(temp);
|
||||
auto temphandles = std::make_unique<tbb::concurrent_vector<DatedHandle>>();
|
||||
@@ -92,7 +92,6 @@ struct MDConsumerGroup {
|
||||
}
|
||||
|
||||
UserSymbol symbol;
|
||||
std::shared_ptr<api::ISyntheticSecurityService> synt;
|
||||
Platform platform;
|
||||
MDConsumer consumer;
|
||||
MDConsumerChannel channel;
|
||||
@@ -139,11 +138,11 @@ public:
|
||||
InternalMap::const_iterator find(const UserSymbol& symbol) const { return _map.find(symbol); }
|
||||
};
|
||||
|
||||
Map form_groups(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss) {
|
||||
Map form_groups(const std::set<UserSymbol>& symbols) {
|
||||
// todo: Probably want to pass null for ss for everything except the last one
|
||||
boost::container::flat_map<UserSymbol, shared_ptr<MDConsumerGroup>> groups;
|
||||
for (const auto& sym : symbols) {
|
||||
groups.emplace(std::make_pair(sym, std::make_unique<MDConsumerGroup>(sym, ss)));
|
||||
groups.emplace(std::make_pair(sym, std::make_unique<MDConsumerGroup>(sym)));
|
||||
}
|
||||
groups.shrink_to_fit();
|
||||
return Map(groups);
|
||||
@@ -177,9 +176,14 @@ void copy_misc(MiscData misc, co2::MiscMessage* pmisc) {
|
||||
}
|
||||
|
||||
// Handles market data queries and responds
|
||||
struct QueryServerImpl : public IQueryServer {
|
||||
class QueryServerImpl : public IQueryServer {
|
||||
MDConsumer consumer;
|
||||
Map groups;
|
||||
|
||||
public:
|
||||
QueryServerImpl(const std::set<UserSymbol>& symbols, std::shared_ptr<api::ISyntheticSecurityService>& ss) :
|
||||
groups(form_groups(symbols, ss))
|
||||
consumer(symbols, ss),
|
||||
groups(form_groups(symbols))
|
||||
{ }
|
||||
|
||||
// Scan for new securities and get their handles+times
|
||||
@@ -331,8 +335,6 @@ struct QueryServerImpl : public IQueryServer {
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
Map groups;
|
||||
};
|
||||
|
||||
struct MDRelayServer : bts::co2::MarketDataRelayBase {
|
||||
|
||||
Reference in new issue
Block a user