* src/threads/threadlist.cpp (foo): Removed.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 9 Sep 2008 12:52:26 +0000 (14:52 +0200)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Tue, 9 Sep 2008 12:52:26 +0000 (14:52 +0200)
(get_thread_by_index): Use comparator.
* src/threads/threadlist.hpp (ThreadList): Added comparator class.

src/threads/threadlist.cpp
src/threads/threadlist.hpp

index 6a5309315e812e858c5c72324629241e4e689225..bcf7f0e18e80cf06709307d497fade4484eb7a8a 100644 (file)
@@ -177,20 +177,11 @@ int32_t ThreadList::get_number_of_non_daemon_threads(void)
  *
  * @return thread object
  */
-
-class foo : public std::binary_function<threadobject*, int32_t, bool> {
-public:
-       bool operator() (const threadobject* t, const int32_t index) const
-       {
-               return (t->index == index);
-       }
-};
-
 threadobject* ThreadList::get_thread_by_index(int32_t index)
 {
        lock();
 
-       List<threadobject*>::iterator it = find_if(_active_thread_list.begin(), _active_thread_list.end(), std::bind2nd(foo(), index));
+       List<threadobject*>::iterator it = find_if(_active_thread_list.begin(), _active_thread_list.end(), std::bind2nd(comparator(), index));
 
        // No thread found.
        if (it == _active_thread_list.end()) {
index 5fb28c54bfc30abced82ec84271ea4f78ec12761..2a9f2059c296ce538ca1e60be51fe0d01424ff15 100644 (file)
@@ -55,6 +55,16 @@ private:
        static inline void          add_to_free_thread_list(threadobject* t);
        static inline void          add_to_free_index_list(int32_t index);
 
+private:
+       // Comparator class.
+       class comparator : public std::binary_function<threadobject*, int32_t, bool> {
+       public:
+               bool operator() (const threadobject* t, const int32_t index) const
+               {
+                       return (t->index == index);
+               }
+       };
+
 public:
        static inline void          lock()   { _mutex.lock(); }
        static inline void          unlock() { _mutex.unlock(); }