4#ifndef REQUEST_MANAGER_H
5#define REQUEST_MANAGER_H
7#include <unordered_set>
8#include <unordered_map>
13#include "ClientDataManager.h"
15typedef std::pair<Request*, int8_t> RequestInfo;
22enum RequestProcessingStatus : int8_t {
38 static std::shared_ptr<RequestManager> mReqeustManagerInstance;
39 static std::mutex instanceProtectionLock;
41 int64_t mTotalRequestServed;
42 std::unordered_set<Request*> mRequestsList[2];
43 std::unordered_map<int64_t, RequestInfo> mActiveRequests;
44 MinLRUCache mUntuneCache;
45 std::shared_timed_mutex mRequestMapMutex;
50 int8_t isSane(
Request* request);
51 int8_t requestMatch(
Request* request);
116 void markRequestAsComplete(int64_t handle);
118 int8_t getRequestProcessingStatus(int64_t handle);
120 std::vector<Request*> getPendingList();
135 static std::shared_ptr<RequestManager> getInstance() {
136 if(mReqeustManagerInstance ==
nullptr) {
137 instanceProtectionLock.lock();
138 if(mReqeustManagerInstance ==
nullptr) {
140 mReqeustManagerInstance = std::shared_ptr<RequestManager> (
new RequestManager());
141 }
catch(
const std::bad_alloc& e) {
142 instanceProtectionLock.unlock();
146 instanceProtectionLock.unlock();
148 return mReqeustManagerInstance;
int8_t disableRequestProcessing(int64_t handle)
Mark the Request Handle, so that the Request won't be applied.
void moveToPendingList()
Handles Device Mode transition from RESUME to SUSPEND.
RequestInfo getRequestFromMap(int64_t handle)
Retrieve the Request with the given Handle.
int64_t getActiveReqeustsCount()
Get the current Global Active Requests Count.
int8_t addRequest(Request *request)
Add the specified request to the RequestMap.
void removeRequest(Request *request)
Remove a given request from the RequestMap.
int8_t verifyHandle(int64_t handle)
Check if a Request with the specified handle exists in the RequestMap.
int8_t shouldRequestBeAdded(Request *request)
Checks whether the specified Request should be added to the RequestMap.
Encapsulation type for a Resource Provisioning Request.