Skip to content

Commit

Permalink
f9fmkt_TradingRequestSt 增加: 遠端支援繞送的相關狀態.
Browse files Browse the repository at this point in the history
  • Loading branch information
fonwin committed Jan 10, 2023
1 parent 01a4ff1 commit 1349422
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
14 changes: 12 additions & 2 deletions fon9/fmkt/FmktTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 193,23 @@ fon9_ENUM(f9fmkt_TradingRequestSt, uint8_t) {
/// 下單要求在另一台主機排隊.
f9fmkt_TradingRequestSt_QueuingAtOther = 0x21,

/// 請求遠端支援送出.
/// 若遭遠端退回, 則有可能會回到 f9fmkt_TradingRequestSt_Queuing;
f9fmkt_TradingRequestSt_AskToRemote = 0x2a,
/// 遠端支援退回, 遠端可能在收到下單要求時, 無可用線路, 或流量管制.
/// 退回原因需參考 ErrCode;
f9fmkt_TradingRequestSt_BackFromRemote = 0x2b,

/// 在呼叫 io.Send() 之前設定的狀態.
/// 您可以自行決定要在 io.Send() 之前 or 之後 or both, 設定送出狀態.
f9fmkt_TradingRequestSt_Sending = 0x30,
/// 在呼叫 io.Send() 之後設定的狀態.
/// 如果要在送出後設定狀態: 則要小心考慮在 io.Send() 之後, 設定 Sent 之前, 就已收到送出的結果.
f9fmkt_TradingRequestSt_Sent = 0x38,

/// 小於等於此值表示: 處理過程的狀態變化, 表示仍在處理中.
/// 小於等於 f9fmkt_TradingRequestSt_LastRunStep 表示:
/// [下單要求流程]處理過程的狀態變化, [下單要求流程]仍在處理中.
/// 與母單無關, 母單使用 f9fmkt_TradingRequestSt_ParentDone 來判斷.
f9fmkt_TradingRequestSt_LastRunStep = 0x9f,

/// 交易所部分回報: 有些下單要求交易所會有多次回報.
Expand All @@ -225,7 234,7 @@ fon9_ENUM(f9fmkt_TradingRequestSt, uint8_t) {
/// 此部分回報為失敗.
f9fmkt_TradingRequestSt_PartExchangeRejected = 0xae,

/// 下單要求流程已結束.
/// >=f9fmkt_TradingRequestSt_Done 表示: 下單要求流程已結束, 下單要求失敗, 或已收到回報結果.
f9fmkt_TradingRequestSt_Done = 0xda,

// 不明原因結束, 無法確定此要求是否成功.
Expand Down Expand Up @@ -375,6 384,7 @@ fon9_ENUM(f9fmkt_OrderSt, uint8_t) {
f9fmkt_OrderSt_NewChecking = f9fmkt_TradingRequestSt_Checking,
f9fmkt_OrderSt_NewQueuing = f9fmkt_TradingRequestSt_Queuing,
f9fmkt_OrderSt_NewQueuingAtOther = f9fmkt_TradingRequestSt_QueuingAtOther,
f9fmkt_OrderSt_NewAskToRemote = f9fmkt_TradingRequestSt_AskToRemote,
f9fmkt_OrderSt_NewSending = f9fmkt_TradingRequestSt_Sending,
f9fmkt_OrderSt_NewSent = f9fmkt_TradingRequestSt_Sent,

Expand Down
12 changes: 12 additions & 0 deletions fon9/fmkt/TradingLine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 221,8 @@ class fon9_API TradingLineManager {
/// - 觸發 OnHelperBroken() 事件:
/// 若現在沒有可用線路, 則會拒絕正在排隊中的委託.
void UpdateHelper(TradingLineHelperSP helper);
void UpdateHelperReady();
void UpdateHelperBroken();

protected:
/// 衍生者在解構時, 應先呼叫此處,
Expand Down Expand Up @@ -386,6 388,16 @@ class fon9_API TradingLineManagerEv : public intrusive_ref_counter<TradingLineMa
/// TradingLineManager 解構, 或設定新的 EvHandler 時通知.
virtual void OnTradingLineManagerDetach(const TLineLocker& tsvrFrom);
};
inline void TradingLineManager::UpdateHelperReady() {
Locker tsvr{this->TradingSvr_};
assert(tsvr->Helper_ && tsvr->Helper_->IsHelperReady());
this->OnHelperReady(std::move(tsvr));
}
inline void TradingLineManager::UpdateHelperBroken() {
Locker tsvr{this->TradingSvr_};
assert(!tsvr->Helper_ || !tsvr->Helper_->IsHelperReady());
this->OnHelperBroken(std::move(tsvr));
}

} } // namespaces
#endif//__fon9_fmkt_TradingLine_hpp__

0 comments on commit 1349422

Please sign in to comment.