开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: com.ib.controller.ApiController thread safety discussion


 

FWIW, I think IBK did about the best that could be done by putting out there a minimal library capable of demo executions, yet is amenable?to taking in different architectural directions via layering on a higher level library or even performing ground rewriting of a new library using the IBK one as a low level API exemplar.? And for this reason alone I think they did the right thing in rejecting the patch even if the work was exemplary.? ??

I think they just want a minimalistic implementation of the API and not bias it any further than necessary towards one concurrent architectural?approach versus another.??

The down side of course is the observation?of the endless stream of toe stubs by fresh users of IBK's?API, which while inherently concurrent and async in nature is without? much builtin current and async support.? It also shows that there is a true demand for higher level libraries that offer correct, easy(ier) to use concurrent/async capability out-of-the-box.? ?

If well constructed?your library will certainly gain traction.

On Thu, Apr 22, 2021 at 12:26 PM Artyom T. <artyom.tyazhelov@...> wrote:

Hi

Good progress was made to make com.ib.controller.ApiController thread-safe. Besides thread-safety, this branch contains re-implementation of error propagation approach.

Lets discuss implementation is here:

Thread-safe order placement :

?

Implementation notes:
?- propagate error back to original handler for any reqXXX call

?- ApiController.reqXXX methods modify?m_reqId and m_requestMap, in a lock-free manner, everything else is local variables

?-?EClient.reqXXX methods already thread-safe, no need to worry about calling them from parallel threads

?- TWS expects growing sequence id only for order placement calls. see?ApiController.java line 1144 for a solution, order_id sequence and socket write are within synchronization block, thus, sequence and order of writing to a socket will be preserved

?

General notes:

- thread-safe use of reqXXX methods is necessity

- thread-safe order placement is byproduct of the fact, that every other method is thread safe

?

Artyom

?

?

?

Join [email protected] to automatically receive all group messages.