License:
Author:
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import tango.io.selector.PollSelector; Socket socket; ISelector selector = new PollSelector(); selector.open(100, 10); // Register to read from socket selector.register(socket, Event.Read); int eventCount = selector.select(0.1); // 0.1 seconds if (eventCount > 0) { // We can now read from the socket socket.read(); } else if (eventCount == 0) { // Timeout } else if (eventCount == -1) { // Another thread called the wakeup() method. } else { // Error: should never happen. } selector.close(); |
Parameters:
size | maximum amount of conduits that will be registered; it will grow dynamically if needed. |
maxEvents | maximum amount of conduit events that will be returned in the selection set per call to select(); this value is currently not used by this selector. |
Remarks:
Parameters:
conduit | conduit that will be associated to the selector; must be a valid conduit (i.e. not null and open). |
events | bit mask of Event values that represent the events that will be tracked for the conduit. |
attachment | optional object with application-specific data that will be available when an event is triggered for the conduit |
Throws:
Examples:
1 | selector.register(conduit, Event.Read | Event.Write, object); |
Parameters:
conduit | conduit that had been previously associated to the selector; it can be null. |
Remarks:
Throws:
Parameters:
timeout | Timespan with the maximum amount of time that the selector will wait for events from the conduits; the amount of time is relative to the current system time (i.e. just the number of milliseconds that the selector has to wait for the events). |
Returns:
Throws:
Remarks:
Remarks: