mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-02 09:00:14 -06:00
#14683 Serve liveness requests on the gRPC server thread
Requests are queued by the completion queue thread and processed from the main thread. A long running request, or an open progress dialog in the GUI, therefore left every request unanswered for as long as that operation lasted, including the liveness checks a client uses to decide whether ResInsight is still there. Let a callback declare that it touches no application state, and serve those directly on the completion queue thread instead of queueing them. GetVersion is the only such callback, since it reads compile-time constants only. Everything that touches the project or the data model is still processed on the main thread, so no request can observe or modify the data model while another one is running. The allocated callback list is now used from both threads and is guarded by a mutex. Shutdown takes a lock before flagging that it is in progress, so that it waits for any dispatch already running on the completion queue thread and no new request handler can be registered on a queue that is about to be shut down. During a blocking call of 3.25 s, 65 pings were answered with a maximum latency of 6.2 ms. Before this change none of them were answered until the call completed.
This commit is contained in:
1 parent
32f97bd862
commit
35614d160e
5 files changed
+124
-8
No files matched your search
@@ -93,11 +93,13 @@ ReplyT& RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>::reply()
|
||||
template <typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::RiaGrpcUnaryCallback( ServiceT* service,
|
||||
MethodImplT methodImpl,
|
||||
MethodRequestT methodRequest )
|
||||
MethodRequestT methodRequest,
|
||||
bool runsOnServerThread )
|
||||
: RiaGrpcServiceCallback<ServiceT, RequestT, ReplyT>( service )
|
||||
, m_responder( &m_context )
|
||||
, m_methodImpl( methodImpl )
|
||||
, m_methodRequest( methodRequest )
|
||||
, m_runsOnServerThread( runsOnServerThread )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -107,7 +109,10 @@ RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::RiaGrpcUnaryCallback( ServiceT
|
||||
template <typename ServiceT, typename RequestT, typename ReplyT>
|
||||
RiaGrpcCallbackInterface* RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>::createNewFromThis() const
|
||||
{
|
||||
return new RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>( this->m_service, this->m_methodImpl, this->m_methodRequest );
|
||||
return new RiaGrpcUnaryCallback<ServiceT, RequestT, ReplyT>( this->m_service,
|
||||
this->m_methodImpl,
|
||||
this->m_methodRequest,
|
||||
m_runsOnServerThread );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user