thread_lists.C
上传用户:shtangtang
上传日期:2007-01-04
资源大小:167k
文件大小:1k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #include <thread_mutex.h>
  2. #include <thread.h>
  3. #include <thread_lists.h>
  4. #include <thread_signal_num.h>
  5. extern "C" {
  6. #  include <signal.h>
  7. };
  8. thread_list::iterator
  9. thread_list::locate(int id)
  10. {
  11.   iterator i;
  12.   for(i=begin();i!=end();i++)
  13.     if ((*i)->id() == id)
  14.       return i;
  15.   return end();
  16. }
  17. void thread_list::remove(int id)
  18. {
  19.   iterator i = locate(id);
  20.   if (i != end())
  21.     erase(i);
  22. }
  23. void thread_list::restart(int id)
  24. {
  25.   kill(id, PTHREAD_SIG_RESTART);
  26. }
  27. void thread_list::suspend(int id)
  28. {
  29.   iterator i = locate(id);
  30.   if (i != end())
  31.     (*i)->suspend();
  32. }
  33.  
  34. pthread *thread_list::self()
  35. {
  36.   iterator i = locate(getpid());
  37.   if (i != end())
  38.     return (*i);
  39.   return 0;
  40. }