thread_lists.C
上传用户:shtangtang
上传日期:2007-01-04
资源大小:167k
文件大小:1k
- #include <thread_mutex.h>
- #include <thread.h>
- #include <thread_lists.h>
- #include <thread_signal_num.h>
- extern "C" {
- # include <signal.h>
- };
- thread_list::iterator
- thread_list::locate(int id)
- {
- iterator i;
- for(i=begin();i!=end();i++)
- if ((*i)->id() == id)
- return i;
- return end();
- }
- void thread_list::remove(int id)
- {
- iterator i = locate(id);
- if (i != end())
- erase(i);
- }
- void thread_list::restart(int id)
- {
- kill(id, PTHREAD_SIG_RESTART);
- }
- void thread_list::suspend(int id)
- {
- iterator i = locate(id);
- if (i != end())
- (*i)->suspend();
- }
-
- pthread *thread_list::self()
- {
- iterator i = locate(getpid());
- if (i != end())
- return (*i);
- return 0;
- }