Class for controlling async socket I/O.
More...
#include <AsyncSocketIoController.qc.dox.h>
Inherits LoggerWrapper.
|
bool | cancel (Socket sock) |
| Cancels any operation in progress for the given Socket.
|
|
| cancelEx (Socket sock) |
| Cancels any operation in progress for the given Socket.
|
|
| constructor (*LoggerInterface logger) |
| Creates the object.
|
|
| constructor (bool autostop, *LoggerInterface logger) |
| For listener sockets.
|
|
| destructor () |
| Stops the monitoring thread and destroys the object.
|
|
hash< SocketPollResultInfo > | exec (hash< SocketPollOperationInfo > info, *bool replace) |
| Executes a socket operation asynchronously and waits for the results.
|
|
bool | getAutostop () |
| Get autostop flag.
|
|
hash< auto > | getInfo () |
| Returns information about the object.
|
|
bool | running () |
| Returns True if the I/O thread is running.
|
|
| setAutostop (bool autostop=True) |
| Set autostop flag.
|
|
| start () |
| Starts monitoring.
|
|
| stop () |
| Stops monitoring.
|
|
| stopClear () |
| Stops monitoring and clears all connections.
|
|
Queue | submit (hash< SocketPollOperationInfo > info, *bool replace) |
| Submits a socket operation to be performed and returns a Queue where the results will be returned.
|
|
| waitStop () |
| Waits for the monitoring thread to stop if it's running.
|
|
|
const | DefaultIoOperationTimeout = 30s |
| Default I/O timeout duration.
|
|
const | PollEventMap = ... |
| Polling event map.
|
|
|
| cancelIntern (string uh) |
| Cancels an operation in progress and sends an appropriate message on the result queue.
|
|
| constructorInit () |
| Common constructor code.
|
|
Mutex | m () |
| Lock for atomic actions.
|
|
|
bool | autostop = True |
| Stop monitoring thread when the last operation is complete.
|
|
hash< string, hash< PollInfo > > | cache |
| Socket cache; unique hash -> poll info.
|
|
const | IO_ADD = "add" |
| I/O thread command: add.
|
|
const | IO_CANCEL = "cancel" |
| I/O thread command: cancel.
|
|
const | IO_QUIT = "quit" |
| I/O thread command: quit.
|
|
int | tid |
| I/O thread TID.
|
|
|
Queue | cmdq () |
| I/O thread command queue.
|
|
Counter | mcnt () |
| I/O thread counter.
|
|
|
hash< string, Condition > | cancel_cond_map |
| Cancel operation waiting Condition; socket unique key -> Condition.
|
|
hash< SocketPollInfo > | sem_info |
| Semaphore descriptor info.
|
|
ReadOnlyFile | sem_read |
| File to read in the I/O thread.
|
|
File | sem_write |
| File to signal the I/O thread.
|
|
Class for controlling async socket I/O.
◆ cancel()
bool AsyncSocketIo::AsyncSocketIoController::cancel |
( |
Socket |
sock | ) |
|
Cancels any operation in progress for the given Socket.
- Parameters
-
sock | the socket to cancel any operation in progress for |
- Returns
- True if an operation for the socket was canceled, False if not
- Note
- Stops the I/O thread if the last operation is canceled and the autostop flag is enabled
- See also
- cancelEx()
◆ cancelEx()
AsyncSocketIo::AsyncSocketIoController::cancelEx |
( |
Socket |
sock | ) |
|
Cancels any operation in progress for the given Socket.
- Parameters
-
sock | the socket to cancel any operation in progress for |
- Returns
- True if an operation for the socket was canceled, False if not
- Note
- Stops the I/O thread if the last operation is canceled and the autostop flag is enabled
- Exceptions
-
CONTROLLER-CANCEL-ERROR | thrown if the Socket has no operation in progress |
- See also
- cancel()
◆ constructor()
AsyncSocketIo::AsyncSocketIoController::constructor |
( |
bool |
autostop, |
|
|
*LoggerInterface |
logger |
|
) |
| |
For listener sockets.
Creates the object
◆ exec()
Executes a socket operation asynchronously and waits for the results.
- Parameters
-
info | a hash with the socket operation and supporting info |
replace | if True, then any operation currently in place for the given socket will be replaced |
- Returns
- The result of the asynchronous operation
- Exceptions
-
CONTROLLER-ADD-ERROR | invalid or incomplete data in info; a different operation on this socket is already in progress |
◆ start()
AsyncSocketIo::AsyncSocketIoController::start |
( |
| ) |
|
Starts monitoring.
- Exceptions
-
CONTROLLER-START-ERROR | if the I/O thread is already running |
◆ submit()
Submits a socket operation to be performed and returns a Queue where the results will be returned.
- Parameters
-
info | a hash with the socket operation and supporting info |
replace | if True, then any operation currently in place for the given socket will be replaced |
- Returns
- Queue a Queue that will have the result of the operation pushed to it
- Exceptions
-
CONTROLLER-ADD-ERROR | invalid or incomplete data in info; a different operation on this socket is already in progress |