$darkmode
Class for monitoring connection supporting the polling API. More...
Inherits LoggerWrapper.
Public Member Functions | |
| add (AbstractConnection conn, *hash< auto > other) | |
| Adds a connection to be monitored. More... | |
| addOrUpdate (AbstractConnection conn, *hash< auto > other) | |
| Adds or updates an existing connection that is already being monitored. More... | |
| constructor (*LoggerInterface logger) | |
| Creates the object. | |
| destructor () | |
| Stops the monitoring thread and destroys the object. | |
| bool | getAutostart () |
| Get autostart flag. | |
| bool | removeConnection (string name) |
| Removes the given connection. More... | |
| removeConnectionEx (string name) | |
| Removes the given connection. More... | |
| bool | running () |
| Returns True if the I/O thread is running. | |
| setAutostart (bool autostart=True) | |
| Set autostart flag. | |
| start () | |
| Starts monitoring. More... | |
| stop () | |
| Stops monitoring. | |
| stopClear () | |
| Stops monitoring and clears all connections. | |
Public Attributes | |
| const | PollEventMap |
| Polling event map. | |
Protected Member Functions | |
| handlePingFailed (string name, date delta, hash< ExceptionInfo > ex) | |
| Handles a failed ping. | |
| handlePingSuccess (string name, date delta, *bool oldok) | |
| Handles a successful ping. | |
| handlePingTimeout (string name, date delta) | |
| Handles a poll timeout. | |
| handlePingTimeoutIntern (string name, date delta) | |
| Handles a ping timeout. | |
| Mutex | m () |
| Lock for atomic actions. | |
| restartPing (string name, *bool force_restart) | |
| Restarts a ping operation. | |
Protected Attributes | |
| bool | autostart = True |
| Autostart monitoring thread with first connection. | |
| hash< string, hash< PollInfo > > | cache |
| Connection cache; unique name -> connection object wrapper. | |
| const | DefaultPingRepeat = 1m |
| Default ping repeat duration. | |
| const | DefaultPingTimeout = 30s |
| Default ping timeout duration. | |
| const | IO_ADD = "add" |
| I/O thread command: add. | |
| const | IO_QUIT = "quit" |
| I/O thread command: quit. | |
| const | IO_QUIT_REMOVE_ALL = "quit-remove-all" |
| I/O thread command: quit and remove all connection. | |
| const | IO_REMOVE = "remove" |
| I/O thread command: remove. | |
| const | IO_UPDATE = "update" |
| I/O thread command: update. | |
| date | ping_repeat = DefaultPingRepeat |
| ping repeat duration | |
| date | ping_timeout = DefaultPingTimeout |
| ping timeout duration | |
| int | tid |
| I/O thread TID. | |
Private Member Functions | |
| Queue | cmdq () |
| I/O thread command queue. | |
| Counter | mcnt () |
| I/O thread counter. | |
Private Attributes | |
| 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 monitoring connection supporting the polling API.
| ConnectionProvider::PollingConnectionMonitor::add | ( | AbstractConnection | conn, |
| *hash< auto > | other | ||
| ) |
Adds a connection to be monitored.
| conn | the connection to be monitored; must support the connection polling API |
| other | a free-form hash to be stored alongside the connection |
| MONITOR-CONNECTION-ERROR | the connection does not support the connection polling API |
| MONITOR-ADD-ERROR | a different connection with this name is already being monitored |
| ConnectionProvider::PollingConnectionMonitor::addOrUpdate | ( | AbstractConnection | conn, |
| *hash< auto > | other | ||
| ) |
Adds or updates an existing connection that is already being monitored.
| conn | the connection to be monitored; must support the connection polling API |
| other | a free-form hash to be stored alongside the connection |
| MONITOR-CONNECTION-ERROR | the connection does not support the connection polling API |
| bool ConnectionProvider::PollingConnectionMonitor::removeConnection | ( | string | name | ) |
Removes the given connection.
| name | the connection to be removed |
| ConnectionProvider::PollingConnectionMonitor::removeConnectionEx | ( | string | name | ) |
Removes the given connection.
| name | the connection to be removed |
| MONITOR-REMOVE-ERROR | thrown if the named connection is not being monitored |
| ConnectionProvider::PollingConnectionMonitor::start | ( | ) |
Starts monitoring.
| MONITOR-START-ERROR | if the I/O thread is already running |