+
+class RequestStorage {
+private:
+ req_storage_t store;
+
+public:
+ RequestStorage() {}
+ int size()
+ {
+ return store.size();
+ }
+
+ req_storage_t& get_store()
+ {
+ return store;
+ }
+
+ void get_requests(std::vector<MPI_Request>& vec)
+ {
+ for (auto& pair : store) {
+ auto& req = pair.second;
+ auto my_proc_id = simgrid::s4u::this_actor::get_pid();
+ if (req != MPI_REQUEST_NULL && (req->src() == my_proc_id || req->dst() == my_proc_id)) {
+ vec.push_back(pair.second);
+ pair.second->print_request("MM");
+ }
+ }
+ }
+
+ MPI_Request find(int src, int dst, int tag)
+ {
+ req_storage_t::iterator it = store.find(req_key_t(src, dst, tag));
+ return (it == store.end()) ? MPI_REQUEST_NULL : it->second;
+ }
+
+ void remove(MPI_Request req)
+ {
+ if (req == MPI_REQUEST_NULL) return;
+
+ store.erase(req_key_t(req->src()-1, req->dst()-1, req->tag()));
+ }
+
+ void add(MPI_Request req)
+ {
+ if (req != MPI_REQUEST_NULL) // Can and does happen in the case of TestAction
+ store.insert({req_key_t(req->src()-1, req->dst()-1, req->tag()), req});
+ }
+
+ /* Sometimes we need to re-insert MPI_REQUEST_NULL but we still need src,dst and tag */
+ void addNullRequest(int src, int dst, int tag)
+ {
+ store.insert({req_key_t(src, dst, tag), MPI_REQUEST_NULL});
+ }
+};
+
+/**
+ * Base class for all parsers.
+ */