我是交易应用程序的初级开发人员......我们有一个订单刷新验证单元。它必须验证来自交易所的订单确认。我们批量发送一堆不同的请求(NEW、MODIFY、CANCEL)进行交换……验证必须进行最多 N 次,所有订单的每个 T 间隔。如果 N 重试之前所有订单验证成功,则可以。否则我们需要指示验证不成功。我做了一个非常紧急的基本编码,如下所示
for( N times )
{
for_each ( sent_request_order ) // SENT
{
1) get all the refreshed order from DB or shared mem i.e REFRESHED
2) find current sent order in REFRESHED
if( not_found )
not refreshed from exchange, continue to next order
if( found )
case NEW : //check for new status, mark verification done
case MODIFY : //check for modified status..
//if not mark pending, go to next order,
//revisit the same after T time
case CANCEL : //check for cancelled status..
//if not mark pending, go to next order,
//revisit the same after T time
}
if( all_verified )
exit from verification.
wait ( T sec )
}
order_verification_pending, order_verification_done, order_visited, order_not_visited, all_verified, all_not_verified ...大量用于指示的布尔标志..
有没有更好的方法来做到这一点......在类之间划分职责......????
我知道这不是一个普遍的问题....但是旗帜仍然让我处理起来很麻烦...