c++ CallbackApi: thread safety

134 views
Skip to first unread message

Oleg Linkin

unread,
Aug 9, 2021, 9:18:38 AM8/9/21
to grpc.io
Is Callback api thread safe?
Should I use mutex in onReadDone/onWriteDone/onDone or they are thread safe on grpc level?
Thank you.

Mark D. Roth

unread,
Aug 11, 2021, 1:00:23 PM8/11/21
to grpc.io
There can only be one outstanding read or write at a given time on a given stream, but reads and writes can happen in parallel.  So you're guaranteed that no more than one thread will be in OnReadDone() at once, and no more than one thread will be in OnWriteDone() at once, but you could have one thread in OnReadDone() while another thread is in OnWriteDone().

OnDone() will not be invoked until after all of the other reaction methods are complete.

Reply all
Reply to author
Forward
0 new messages