File src/utils/selector.h changed (mode: 100644) (index abc510ce5..ffd7c3984) |
... |
... |
void selector_reset(selector_t *selector); |
45 |
45 |
/* Adds item to the set of objects to watch. If error occurs, its ignored. */ |
/* Adds item to the set of objects to watch. If error occurs, its ignored. */ |
46 |
46 |
void selector_add(selector_t *selector, selector_item_t item); |
void selector_add(selector_t *selector, selector_item_t item); |
47 |
47 |
|
|
48 |
|
/* Removes item from the set of objects to watch. */ |
|
49 |
|
void selector_remove(selector_t *selector, selector_item_t item); |
|
50 |
|
|
|
51 |
48 |
/* Waits for at least one of watched objects to become available for reading |
/* Waits for at least one of watched objects to become available for reading |
52 |
49 |
* from during the period of time specified by the delay in milliseconds. |
* from during the period of time specified by the delay in milliseconds. |
53 |
50 |
* Returns zero on error or if timeout was reached without any of the objects |
* Returns zero on error or if timeout was reached without any of the objects |
File src/utils/selector_nix.c changed (mode: 100644) (index 959a1e57a..9ee1897ce) |
... |
... |
selector_add(selector_t *selector, selector_item_t item) |
66 |
66 |
} |
} |
67 |
67 |
} |
} |
68 |
68 |
|
|
69 |
|
void |
|
70 |
|
selector_remove(selector_t *selector, selector_item_t item) |
|
71 |
|
{ |
|
72 |
|
FD_CLR(item, &selector->set); |
|
73 |
|
if(item == selector->max_fd) |
|
74 |
|
{ |
|
75 |
|
/* Could do more here. */ |
|
76 |
|
--selector->max_fd; |
|
77 |
|
} |
|
78 |
|
} |
|
79 |
|
|
|
80 |
69 |
int |
int |
81 |
70 |
selector_wait(selector_t *selector, int delay) |
selector_wait(selector_t *selector, int delay) |
82 |
71 |
{ |
{ |
File src/utils/selector_win.c changed (mode: 100644) (index 20104f118..1fcea2c27) |
... |
... |
selector_add(selector_t *selector, selector_item_t item) |
90 |
90 |
selector->items[selector->size++] = item; |
selector->items[selector->size++] = item; |
91 |
91 |
} |
} |
92 |
92 |
|
|
93 |
|
void |
|
94 |
|
selector_remove(selector_t *selector, selector_item_t item) |
|
95 |
|
{ |
|
96 |
|
int i; |
|
97 |
|
for(i = 0; i < selector->size; ++i) |
|
98 |
|
{ |
|
99 |
|
if(selector->items[i] == item) |
|
100 |
|
{ |
|
101 |
|
selector->items[i] = selector->items[--selector->size]; |
|
102 |
|
break; |
|
103 |
|
} |
|
104 |
|
} |
|
105 |
|
} |
|
106 |
|
|
|
107 |
93 |
int |
int |
108 |
94 |
selector_wait(selector_t *selector, int delay) |
selector_wait(selector_t *selector, int delay) |
109 |
95 |
{ |
{ |