1 | /* |
1 | /* |
2 | iom.h -- generic I/O multiplexor |
2 | iom.h -- generic I/O multiplexer |
3 | Copyright (C) 2003, 2004 Marc Lehmann <pcg@goof.com> |
3 | Copyright (C) 2003, 2004 Marc Lehmann <pcg@goof.com> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
64 | struct sig_watcher; |
64 | struct sig_watcher; |
65 | #endif |
65 | #endif |
66 | |
66 | |
67 | template<class watcher> |
67 | template<class watcher> |
68 | struct io_manager_vec : vector<watcher *> { |
68 | struct io_manager_vec : vector<watcher *> { |
69 | #if IOM_CHECK |
|
|
70 | bool activity; |
|
|
71 | #endif |
|
|
72 | |
|
|
73 | void erase_unordered (unsigned int pos) |
69 | void erase_unordered (unsigned int pos) |
74 | { |
70 | { |
75 | watcher *w = (*this)[this->size () - 1]; |
71 | watcher *w = (*this)[this->size () - 1]; |
76 | this->pop_back (); |
72 | this->pop_back (); |
77 | |
73 | |
78 | if (this->size ()) |
74 | if (!this->empty ()) |
79 | if ((*this)[pos] = w) |
75 | if (((*this)[pos] = w)) // '=' is correct! |
80 | w->active = pos + 1; |
76 | w->active = pos + 1; |
81 | } |
77 | } |
82 | }; |
78 | }; |
83 | |
79 | |
84 | // only used as a namespace, and for initialisation purposes |
80 | // only used as a namespace, and for initialisation purposes |