irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_delay_queue.hpp
Go to the documentation of this file.
1 #include <algorithm>
2 #include <mutex>
3 #include <string>
4 #include <vector>
5 
6 namespace irods {
7  class delay_queue {
8  public:
9  delay_queue() = default;
12 
13  bool contains_rule_id(const std::string& _rule_id) {
14  auto rules_lock{get_queue_lock()};
15  return std::any_of(queued_rules.begin(), queued_rules.end(),
16  [&](const std::string& q_rule){return q_rule == _rule_id;});
17  }
18 
19  void enqueue_rule(const std::string& rule_id) {
20  auto rules_lock{get_queue_lock()};
21  queued_rules.emplace_back(rule_id);
22  }
23 
24  void dequeue_rule(const std::string& rule_id) {
25  auto rules_lock{get_queue_lock()};
26  for(auto it = queued_rules.begin(); it != queued_rules.end(); ++it) {
27  const auto& rule = *it;
28  if(rule == std::string(rule_id)) {
29  queued_rules.erase(it);
30  break;
31  }
32  }
33  }
34 
35  private:
36  std::mutex rules_mutex;
37  std::vector<std::string> queued_rules;
38 
39  std::unique_lock<std::mutex> get_queue_lock() {
40  return std::unique_lock<std::mutex>(rules_mutex);
41  }
42  };
43 }
irods::delay_queue::get_queue_lock
std::unique_lock< std::mutex > get_queue_lock()
Definition: irods_delay_queue.hpp:39
irods::delay_queue::operator=
delay_queue & operator=(delay_queue &)=delete
irods::delay_queue
Definition: irods_delay_queue.hpp:7
irods
Definition: apiHandler.hpp:35
irods::delay_queue::delay_queue
delay_queue()=default
irods::delay_queue::delay_queue
delay_queue(delay_queue &)=delete
irods::delay_queue::enqueue_rule
void enqueue_rule(const std::string &rule_id)
Definition: irods_delay_queue.hpp:19
irods::delay_queue::rules_mutex
std::mutex rules_mutex
Definition: irods_delay_queue.hpp:36
irods::delay_queue::contains_rule_id
bool contains_rule_id(const std::string &_rule_id)
Definition: irods_delay_queue.hpp:13
irods::delay_queue::dequeue_rule
void dequeue_rule(const std::string &rule_id)
Definition: irods_delay_queue.hpp:24
irods::delay_queue::queued_rules
std::vector< std::string > queued_rules
Definition: irods_delay_queue.hpp:37