aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-08-20 11:18:35 +0200
committerEelco Dolstra <edolstra@gmail.com>2021-10-13 12:12:44 +0200
commit262520fcfe2544a7278b6b5967d0d8b605fd89d9 (patch)
tree05750f4917f309c33d50b7dd6265da3879ed4501 /src/libutil
parentff453b06f94b4305694beac8255d9ff51bed1a63 (diff)
Use a thread per connection
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index 528d113db..76f80f7a4 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -511,6 +511,18 @@ std::optional<typename T::mapped_type> get(const T & map, const typename T::key_
}
+/* Remove and return the first item from a container. */
+template <class T>
+std::optional<typename T::value_type> remove_begin(T & c)
+{
+ auto i = c.begin();
+ if (i == c.end()) return {};
+ auto v = std::move(*i);
+ c.erase(i);
+ return v;
+}
+
+
template<typename T>
class Callback;