OmniSciDB
a5dc49c757
|
Stores and allows access to a binary semaphore per RequestId (using an std::unordered_map
), as well as accessing all outstanding RequestIds for waiting requests.
More...
#include <OutstandingQueueRequests.h>
Public Member Functions | |
void | queue_request_and_wait (const RequestId request_id) |
Submits a request with id request_id into the queue, waiting on a BinarySemaphore until ExecutorResourceMgr decides to grant the request resources and wakes the waiting thread. More... | |
void | queue_request_and_wait_with_timeout (const RequestId request_id, const size_t max_wait_in_ms) |
Submits a request with id request_id into the queue, waiting on a BinarySemaphore until ExecutorResourceMgr decides to grant the request resources and wakes the waiting thread. If it waits for a period longer than max_wait_in_ms , a QueryTimedOutWaitingInQueue exception is thrown. More... | |
std::vector< RequestId > | get_outstanding_request_ids () |
Get the RequestId s of all outsanding requests in the queue. More... | |
void | wake_request_by_id (const RequestId request_id) |
Wakes a waiting thread in the queue. Invoked by ExecutorResourceMgr::process_queue_loop() More... | |
Private Types | |
using | OutstandingQueueRequestsMap = std::unordered_map< RequestId, SemaphoreShim_Namespace::BinarySemaphore > |
Private Member Functions | |
SemaphoreShim_Namespace::BinarySemaphore & | get_semaphore_for_request (const RequestId request_id) |
Creates a new entry in outstanding_requests_map_ , assigning a BinarySemaphore for the given requesting thread with id request_id More... | |
void | delete_semaphore_for_request (const RequestId request_id) |
Internal method: removes a RequestId -BinarySemaphore entry from outstanding_requests_map_ . Invoked after a request thread is awoken (including on timeout). More... | |
Private Attributes | |
OutstandingQueueRequestsMap | outstanding_requests_map_ |
Stores a map of RequestId to BinarySemaphore More... | |
std::shared_mutex | requests_map_mutex_ |
Read-write lock protecting the outstanding_requests_map_ More... | |
Stores and allows access to a binary semaphore per RequestId (using an std::unordered_map
), as well as accessing all outstanding RequestIds for waiting requests.
Definition at line 35 of file OutstandingQueueRequests.h.
|
private |
Definition at line 37 of file OutstandingQueueRequests.h.
|
inlineprivate |
Internal method: removes a RequestId
-BinarySemaphore
entry from outstanding_requests_map_
. Invoked after a request thread is awoken (including on timeout).
request_id | - RequestId key to be removed from the outstanding_requests_map_ |
Definition at line 130 of file OutstandingQueueRequests.h.
References CHECK_EQ, outstanding_requests_map_, and requests_map_mutex_.
Referenced by queue_request_and_wait(), and queue_request_and_wait_with_timeout().
|
inline |
Get the RequestId
s of all outsanding requests in the queue.
Definition at line 79 of file OutstandingQueueRequests.h.
References outstanding_requests_map_, and requests_map_mutex_.
|
inlineprivate |
Creates a new entry in outstanding_requests_map_
, assigning a BinarySemaphore
for the given requesting thread with id request_id
request_id | - RequestId for the requesting thread - will be used as a key in outstanding_requests_map_ |
BinarySemaphore
that was added to outstanding_requests_map_
for this request Definition at line 116 of file OutstandingQueueRequests.h.
References outstanding_requests_map_, logger::request_id(), and requests_map_mutex_.
Referenced by queue_request_and_wait(), and queue_request_and_wait_with_timeout().
|
inline |
Submits a request with id request_id
into the queue, waiting on a BinarySemaphore
until ExecutorResourceMgr
decides to grant the request resources and wakes the waiting thread.
request_id | - RequestId for this request |
Definition at line 47 of file OutstandingQueueRequests.h.
References delete_semaphore_for_request(), and get_semaphore_for_request().
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::request_resources_with_timeout().
|
inline |
Submits a request with id request_id
into the queue, waiting on a BinarySemaphore
until ExecutorResourceMgr
decides to grant the request resources and wakes the waiting thread. If it waits for a period longer than max_wait_in_ms
, a QueryTimedOutWaitingInQueue
exception is thrown.
request_id | - RequestId for this request |
Definition at line 61 of file OutstandingQueueRequests.h.
References CHECK_GT, delete_semaphore_for_request(), and get_semaphore_for_request().
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::request_resources_with_timeout().
|
inline |
Wakes a waiting thread in the queue. Invoked by ExecutorResourceMgr::process_queue_loop()
request_id | - RequestId of the request/thread that should be awoken |
Definition at line 95 of file OutstandingQueueRequests.h.
References outstanding_requests_map_, logger::request_id(), and requests_map_mutex_.
Referenced by ExecutorResourceMgr_Namespace::ExecutorResourceMgr::process_queue_loop().
|
private |
Stores a map of RequestId
to BinarySemaphore
Definition at line 140 of file OutstandingQueueRequests.h.
Referenced by delete_semaphore_for_request(), get_outstanding_request_ids(), get_semaphore_for_request(), and wake_request_by_id().
|
mutableprivate |
Read-write lock protecting the outstanding_requests_map_
Definition at line 145 of file OutstandingQueueRequests.h.
Referenced by delete_semaphore_for_request(), get_outstanding_request_ids(), get_semaphore_for_request(), and wake_request_by_id().