]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/common/Thread.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / common / Thread.h
index 54fd750925fe731800e9e4276ec4ffb9e02e0a8a..bc32755c30e887d517dd790a90321182214fa6d8 100644 (file)
@@ -1,4 +1,4 @@
- // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 /*
  * Ceph - scalable distributed file system
 #ifndef CEPH_THREAD_H
 #define CEPH_THREAD_H
 
+#include <system_error>
+#include <thread>
+
 #include <pthread.h>
 #include <sys/types.h>
 
+#include "include/compat.h"
+
+extern pid_t ceph_gettid();
+
 class Thread {
  private:
   pthread_t thread_id;
   pid_t pid;
-  int ioprio_class, ioprio_priority;
   int cpuid;
   const char *thread_name;
 
@@ -52,8 +58,23 @@ class Thread {
   void create(const char *name, size_t stacksize = 0);
   int join(void **prval = 0);
   int detach();
-  int set_ioprio(int cls, int prio);
   int set_affinity(int cpuid);
 };
 
+// Functions for with std::thread
+
+void set_thread_name(std::thread& t, const std::string& s);
+std::string get_thread_name(const std::thread& t);
+void kill(std::thread& t, int signal);
+
+template<typename Fun, typename... Args>
+std::thread make_named_thread(const std::string& s,
+                             Fun&& fun,
+                             Args&& ...args) {
+  auto t = std::thread(std::forward<Fun>(fun),
+                      std::forward<Args>(args)...);
+  set_thread_name(t, s);
+  return t;
+}
+
 #endif