Loading...
Searching...
No Matches
ConnectionProvider::PollingConnectionMonitor Class Reference

Class for monitoring connection supporting the polling API. More...

`#include <PollingConnectionMonitor.qc.dox.h>`

## Public Member Functions

| add (AbstractConnection conn, *hash< auto > other, *bool start_pending)
| Adds a connection to be monitored.
| addOrUpdate (AbstractConnection conn, *hash< auto > other)
| Adds or updates an existing connection that is already being monitored.
| constructor (*LoggerInterface logger)
| Creates the object.
| destructor ()
| Stops the monitoring thread and destroys the object.
bool | getAutostart ()
| Get autostart flag.
hash< auto > | getInfo ()
| Returns information about the object.
bool | removeConnection (string name)
| Removes the given connection.
| removeConnectionEx (string name)
| Removes the given connection.
bool | running ()
| Returns True if the I/O thread is running.
| setAutostart (bool autostart=True)
| Set autostart flag.
| start ()
| Starts monitoring.
| stop ()
| Stops monitoring.
| stopClear ()
| Stops monitoring and clears all connections.
| waitStop ()
| Waits for the monitoring thread to stop if it's running.

## Public Attributes

const | PollEventMap = ...
| Polling event map.

## Protected Member Functions

| failedToStartPing (string name, hash< ExceptionInfo > ex)
| Could not start ping.
| 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.
*hash< ExceptionInfo > | 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_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.

## Detailed Description

Class for monitoring connection supporting the polling API.

Since
  ConnectionProvider 1.7

## Member Function Documentation

## add()

ConnectionProvider::PollingConnectionMonitor::add | ( | AbstractConnection | conn,
|  | *hash< auto > | other,
|  | *bool | start_pending )

Adds a connection to be monitored.

Parameters

  conn | the connection to be monitored; must support the connection polling API
  other | a free-form hash to be stored alongside the connection
  start_pending | wait until the next cycle to poll

Exceptions

  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

## addOrUpdate()

ConnectionProvider::PollingConnectionMonitor::addOrUpdate | ( | AbstractConnection | conn,
|  | *hash< auto > | other )

Adds or updates an existing connection that is already being monitored.

Parameters

  conn | the connection to be monitored; must support the connection polling API
  other | a free-form hash to be stored alongside the connection

Exceptions

  MONITOR-CONNECTION-ERROR | the connection does not support the connection polling API

## removeConnection()

bool ConnectionProvider::PollingConnectionMonitor::removeConnection | ( | string | name | ) |

Removes the given connection.

Parameters

  name | the connection to be removed

Returns
  True if the connection was removed, False if no such connection is being monitored

Note
  Stops the I/O thread if the last connection is removed and the autostart flag is enabled

See also
  removeConnectionEx()

## removeConnectionEx()

ConnectionProvider::PollingConnectionMonitor::removeConnectionEx | ( | string | name | ) |

Removes the given connection.

Parameters

  name | the connection to be removed

Exceptions

  MONITOR-REMOVE-ERROR | thrown if the named connection is not being monitored

See also
  removeConnection()

## restartPing()

*hash< ExceptionInfo > ConnectionProvider::PollingConnectionMonitor::restartPing | ( | string | name,
|  | *bool | force_restart )

protected

Restarts a ping operation.

Returns
  an exception object if the ping could not be started

## start()

ConnectionProvider::PollingConnectionMonitor::start | ( |  | ) |

Starts monitoring.

Exceptions

  MONITOR-START-ERROR | if the I/O thread is already running