]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
thread: remove get_num_threads() static
authorSage Weil <sage.weil@dreamhost.com>
Fri, 4 May 2012 01:51:03 +0000 (18:51 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 4 May 2012 03:01:02 +0000 (20:01 -0700)
This looks in /proc to count threads.  Kludgey and no longer needed.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/common/Thread.cc
src/common/Thread.h

index c0809f07ec958a79d3afdf07d5bedd08e63b86d0..87d9a829befc5fd8e93949f278ce81a10112b15a 100644 (file)
@@ -42,38 +42,6 @@ void *Thread::_entry_func(void *arg) {
   return r;
 }
 
-/**
- * Return the number of threads in this process.
- * So a single-threaded program would have one thread; a program with a main
- * thread and one child thread would have two threads, etc.
- */
-int Thread::get_num_threads(void)
-{
-  std::ostringstream oss;
-  oss << "/proc/" << getpid() << "/task";
-  DIR *dir = opendir(oss.str().c_str());
-  if (!dir) {
-    int err = errno;
-    return -err;
-  }
-  int num_entries = 0;
-  while (true) {
-    struct dirent *e = readdir(dir);
-    if (!e)
-      break;
-    if ((strcmp(e->d_name, ".") == 0) ||
-        (strcmp(e->d_name, "..") == 0))
-      continue;
-    num_entries++;
-  }
-  ::closedir(dir);
-  if (num_entries == 0) {
-    // Shouldn't happen.
-    return -EINVAL;
-  }
-  return num_entries;
-}
-
 const pthread_t &Thread::get_thread_id()
 {
   return thread_id;
index e977652269b25d271f420b4b7ac94d7c2d65a1df..4bc0254b1c26d6121aff69af24b95ff3ebb727be 100644 (file)
@@ -36,7 +36,6 @@ class Thread {
   static void *_entry_func(void *arg);
 
  public:
-  static int get_num_threads(void);
   const pthread_t &get_thread_id();
   bool is_started();
   bool am_self();