Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Elektron /
  • EMA /
avatar image
REFINITIV
Question by cdefusco · Jul 02, 2019 at 12:56 PM · elektronrefinitiv-realtimeelektron-sdkrrtema-apielektron-message-apiapiOMMmulti-threadingmutex

[EMA CPP] Trade Safety of a class that inherits from OmmConsumerClient

Hi, suppose I have a class that inherits from OmmConsumerClient:

class Client : public thomsonreuters::ema::access::OmmConsumerClient
{
public:
    Client();
    ~Client();
    void onRefreshMsg(const thomsonreuters::ema::access::RefreshMsg&, msg, const thomsonreuters::ema::access::OmmConsumerEvent& event);
    void onUpdateMsg(const thomsonreuters::ema::access::UpdateMsg& msg,const thomsonreuters::ema::access::OmmConsumerEvent& event);
    void onStatusMsg(const thomsonreuters::ema::access::StatusMsg& msg, const thomsonreuters::ema::access::OmmConsumerEvent& event);
};

Now suppose that in one or all of the three methods onRefreshMsg, onUpdateMsg, onStatusMsg I have a list or a map readed and writed in a concurrent way (in others words a critical section). Suppose also that I use the thread of EMA library to dispatch the message for these three callback and not a my own thread (using the OmmConsumerConfig::ApiDispatchEnum).

In this scenario, each critical section (as: lists, maps and so on) must to be locked, for example using a mutex/spin lock? Or the call is made in a thread safe way by EMA library?

For example two call of onRefreshMsg for different notification will be thread safe? or there will be an interleaving giving a race condition for structures managed in the method onRefreshMsg?


Thank you.

People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by umer.nalla · Jul 04, 2019 at 04:02 AM

Hi @cdefusco

Each instance of the OmmConsumer will only call one instance of onRefresh/onUpdate/onStatus from the same API thread at a time.

As events (such as Refresh / Update / Status) arrive from the server they are stored in an internal queue. The API thread reads each event from the queue one at a time and calls the appropriate event handler. Once your event handler returns control, the API will then read the next event from the queue and call the event handler and so on..

So, even if you have subscribed to multiple RICs, the single instance of OmmConsumer will only call one event handler at a time.

You can read section 2.4 of the EMA Developer Guide for more information.

Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
Answer by veerapath.rungruengrayubkul · Jul 04, 2019 at 03:31 AM

Hi @cdefusco,

With ApiDispatch mode, the three callback methods; onRefreshMsg, onUpdateMsg, onStatusMsg are invoked by EMA thread. You may need to add a lock for your list or map objects in case that they are accessed by other threads.

Comment

People who like this

0 Show 1 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
REFINITIV
cdefusco · Jul 04, 2019 at 03:53 AM 0
Share

Ok, so two or more consequent call of onRefreshMsg, for example, are however thread safe, right?

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
10 People are following this question.

Related Questions

APIdisptatch mode behaviour, VA Reactor thread in EMA API

Is it possible to enable Hex tracing in EMA C++?

multithreading callback

When processing UpdateMsg using multiple threads, keep getting exception when opening the message. Is there way to clone a message for further processing. I believe the UpdateMsg objects keep getting overridden

Filling EMA messages is not multi-thread-safe.

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges