Permalink
Browse files

add iterator

git-svn-id: http://svn.coderepos.org/share/lang/c/picoev/trunk@35043 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information...
1 parent bb3b5ba commit 9480be784a69cc758b6668cee6ee7bdc703445ca kazuho committed Aug 25, 2009
Showing with 13 additions and 0 deletions.
  1. +13 −0 picoev.h
View
@@ -275,6 +275,19 @@ extern "C" {
return 0;
}
+ /* function to iterate registered information. To start iteration, set curfd
+ to -1 and call the function until -1 is returned */
+ PICOEV_INLINE
+ int picoev_next_fd(picoev_loop* loop, int curfd) {
+ assert(PICOEV_IS_INITED_AND_FD_IN_RANGE(curfd));
+ while (++curfd < picoev.max_fd) {
+ if (loop->loop_id == picoev.fds[curfd].loop_id) {
+ return curfd;
+ }
+ }
+ return -1;
+ }
+
/* internal function */
PICOEV_INLINE
int picoev_init_loop_internal(picoev_loop* loop, int max_timeout) {

0 comments on commit 9480be7

Please sign in to comment.