allow command to accept "--" separator
[folly.git] / folly / PriorityMPMCQueue.h
index b1c0a875bfd0d02ab17dbbfd94d84d297c0bef65..08c498358d498b1bfe2935457142b81c9359677b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,10 @@ namespace folly {
 /// not implement a blocking interface. For the purposes of this
 /// class, lower number is higher priority
 
-template <class T>
+template <
+    typename T,
+    template <typename> class Atom = std::atomic,
+    bool Dynamic = false>
 class PriorityMPMCQueue {
  public:
   PriorityMPMCQueue(size_t numPriorities, size_t capacity) {
@@ -63,6 +66,10 @@ class PriorityMPMCQueue {
     return false;
   }
 
+  bool readWithPriority(T& item, size_t priority) {
+    return queues_[priority].readIfNotEmpty(item);
+  }
+
   size_t size() const {
     size_t total_size = 0;
     for (auto& q : queues_) {
@@ -91,7 +98,7 @@ class PriorityMPMCQueue {
   }
 
  private:
-  std::vector<folly::MPMCQueue<T>> queues_;
+  std::vector<folly::MPMCQueue<T, Atom, Dynamic>> queues_;
 };
 
 } // namespace folly