Skip to content

Commit

Permalink
Allow outside access to callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtheschmitzer committed Mar 28, 2013
1 parent d359b31 commit 5a68a6b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/book/order_book.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class OrderBook {
/// @brief access the asks container
const Asks& asks() const { return asks_; };

/// @brief move callbacks to another thread's container
void move_callbacks(Callbacks& target);

/// @brief perform all callbacks in the queue
virtual void perform_callbacks();

Expand Down Expand Up @@ -595,6 +598,14 @@ OrderBook<OrderPtr>::cross_orders(Tracker& inbound_tracker,
trans_id_));
}

template <class OrderPtr>
inline void
OrderBook<OrderPtr>::move_callbacks(Callbacks& target)
{
target.insert(target.end(), callbacks_.begin(), callbacks_.end());
callbacks_.erase(callbacks_.begin(), callbacks_.end());
}

template <class OrderPtr>
inline void
OrderBook<OrderPtr>::perform_callbacks()
Expand All @@ -610,6 +621,8 @@ template <class OrderPtr>
inline void
OrderBook<OrderPtr>::perform_callback(TypedCallback& cb)
{
// NOTE - this is not yet handled in the parent class. You are requried to
// override in the child.
// If this is an order callback and I know of an order listener
if (cb.order && order_listener_) {
switch (cb.type) {
Expand Down

0 comments on commit 5a68a6b

Please sign in to comment.