Reactor

## Typedefs

typedef struct pn_reactor_t | pn_reactor_t
typedef struct pn_acceptor_t | pn_acceptor_t
typedef struct pn_timer_t | pn_timer_t
typedef struct pn_task_t | pn_task_t
typedef struct pn_handler_t | pn_handler_t
| An event handler. More...

## Functions

PN_EXTERN pn_handler_t * | pn_handler (void(*dispatch)(pn_handler_t *, pn_event_t *, pn_event_type_t))
PN_EXTERN pn_handler_t * | pn_handler_new (void(*dispatch)(pn_handler_t *, pn_event_t *, pn_event_type_t), size_t size, void(*finalize)(pn_handler_t *))
PN_EXTERN void | pn_handler_free (pn_handler_t *handler)
PN_EXTERN void * | pn_handler_mem (pn_handler_t *handler)
PN_EXTERN void | pn_handler_add (pn_handler_t *handler, pn_handler_t *child)
PN_EXTERN void | pn_handler_clear (pn_handler_t *handler)
PN_EXTERN void | pn_handler_dispatch (pn_handler_t *handler, pn_event_t *event, pn_event_type_t type)
PN_EXTERN pn_reactor_t * | pn_reactor (void)
PN_EXTERN pn_record_t * | pn_reactor_attachments (pn_reactor_t *reactor)
PN_EXTERN pn_millis_t | pn_reactor_get_timeout (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_set_timeout (pn_reactor_t *reactor, pn_millis_t timeout)
PN_EXTERN pn_timestamp_t | pn_reactor_mark (pn_reactor_t *reactor)
PN_EXTERN pn_timestamp_t | pn_reactor_now (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_yield (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_free (pn_reactor_t *reactor)
PN_EXTERN pn_collector_t * | pn_reactor_collector (pn_reactor_t *reactor)
PN_EXTERN pn_handler_t * | pn_reactor_get_global_handler (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_set_global_handler (pn_reactor_t *reactor, pn_handler_t *handler)
PN_EXTERN pn_handler_t * | pn_reactor_get_handler (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_set_handler (pn_reactor_t *reactor, pn_handler_t *handler)
PN_EXTERN pn_io_t * | pn_reactor_io (pn_reactor_t *reactor)
PN_EXTERN pn_list_t * | pn_reactor_children (pn_reactor_t *reactor)
PN_EXTERN pn_selectable_t * | pn_reactor_selectable (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_update (pn_reactor_t *reactor, pn_selectable_t *selectable)
PN_EXTERN pn_acceptor_t * | pn_reactor_acceptor (pn_reactor_t *reactor, const char *host, const char *port, pn_handler_t *handler)
PN_EXTERN pn_connection_t * | pn_reactor_connection_to_host (pn_reactor_t *reactor, const char *host, const char *port, pn_handler_t *handler)
| Create an outgoing connection that will be managed by the reactor. More...
PN_EXTERN pn_connection_t * | pn_reactor_connection (pn_reactor_t *reactor, pn_handler_t *handler)
| Create an outgoing connection that will be managed by the reactor. More...
PN_EXTERN void | pn_reactor_set_connection_host (pn_reactor_t *reactor, pn_connection_t *connection, const char *host, const char *port)
| Change the host address used by an outgoing reactor connection. More...
PN_EXTERN const char * | pn_reactor_get_connection_address (pn_reactor_t *reactor, pn_connection_t *connection)
| Retrieve the peer host address for a reactor connection. More...
PN_EXTERN int | pn_reactor_wakeup (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_start (pn_reactor_t *reactor)
PN_EXTERN bool | pn_reactor_quiesced (pn_reactor_t *reactor)
PN_EXTERN bool | pn_reactor_process (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_stop (pn_reactor_t *reactor)
PN_EXTERN void | pn_reactor_run (pn_reactor_t *reactor)
PN_EXTERN pn_task_t * | pn_reactor_schedule (pn_reactor_t *reactor, int delay, pn_handler_t *handler)
PN_EXTERN void | pn_acceptor_set_ssl_domain (pn_acceptor_t *acceptor, pn_ssl_domain_t *domain)
PN_EXTERN void | pn_acceptor_close (pn_acceptor_t *acceptor)
PN_EXTERN pn_acceptor_t * | pn_connection_acceptor (pn_connection_t *connection)
PN_EXTERN pn_timer_t * | pn_timer (pn_collector_t *collector)
PN_EXTERN pn_timestamp_t | pn_timer_deadline (pn_timer_t *timer)
PN_EXTERN void | pn_timer_tick (pn_timer_t *timer, pn_timestamp_t now)
PN_EXTERN pn_task_t * | pn_timer_schedule (pn_timer_t *timer, pn_timestamp_t deadline)
PN_EXTERN int | pn_timer_tasks (pn_timer_t *timer)
PN_EXTERN pn_record_t * | pn_task_attachments (pn_task_t *task)
PN_EXTERN void | pn_task_cancel (pn_task_t *task)
PN_EXTERN pn_reactor_t * | pn_class_reactor (const pn_class_t *clazz, void *object)
PN_EXTERN pn_reactor_t * | pn_object_reactor (void *object)
PN_EXTERN pn_reactor_t * | pn_event_reactor (pn_event_t *event)
PN_EXTERN pn_handler_t * | pn_record_get_handler (pn_record_t *record)
PN_EXTERN void | pn_record_set_handler (pn_record_t *record, pn_handler_t *handler)

## Detailed Description

## Typedef Documentation

## pn_acceptor_t

typedef struct pn_acceptor_t pn_acceptor_t

## pn_handler_t

typedef struct pn_handler_t pn_handler_t

An event handler.

A pn_handler_t is target of pn_event_t dispatched by the pn_reactor_t

## pn_reactor_t

typedef struct pn_reactor_t pn_reactor_t

## pn_task_t

typedef struct pn_task_t pn_task_t

## pn_timer_t

typedef struct pn_timer_t pn_timer_t

## Function Documentation

## pn_acceptor_close()

PN_EXTERN void pn_acceptor_close | ( | pn_acceptor_t * | acceptor | ) |

## pn_acceptor_set_ssl_domain()

PN_EXTERN void pn_acceptor_set_ssl_domain | ( | pn_acceptor_t * | acceptor,
|  | pn_ssl_domain_t * | domain
| ) |  |

## pn_class_reactor()

PN_EXTERN pn_reactor_t* pn_class_reactor | ( | const pn_class_t * | clazz,
|  | void * | object
| ) |  |

## pn_connection_acceptor()

PN_EXTERN pn_acceptor_t* pn_connection_acceptor | ( | pn_connection_t * | connection | ) |

## pn_event_reactor()

PN_EXTERN pn_reactor_t* pn_event_reactor | ( | pn_event_t * | event | ) |

## pn_handler()

PN_EXTERN pn_handler_t* pn_handler | ( | void(*)(pn_handler_t *, pn_event_t *, pn_event_type_t) | dispatch | ) |

## pn_handler_add()

PN_EXTERN void pn_handler_add | ( | pn_handler_t * | handler,
|  | pn_handler_t * | child
| ) |  |

## pn_handler_clear()

PN_EXTERN void pn_handler_clear | ( | pn_handler_t * | handler | ) |

## pn_handler_dispatch()

PN_EXTERN void pn_handler_dispatch | ( | pn_handler_t * | handler,
|  | pn_event_t * | event,
|  | pn_event_type_t | type
| ) |  |

## pn_handler_free()

PN_EXTERN void pn_handler_free | ( | pn_handler_t * | handler | ) |

## pn_handler_mem()

PN_EXTERN void* pn_handler_mem | ( | pn_handler_t * | handler | ) |

## pn_handler_new()

PN_EXTERN pn_handler_t* pn_handler_new | ( | void(*)(pn_handler_t *, pn_event_t *, pn_event_type_t) | dispatch,
|  | size_t | size,
|  | void(*)(pn_handler_t *) | finalize
| ) |  |

## pn_object_reactor()

PN_EXTERN pn_reactor_t* pn_object_reactor | ( | void * | object | ) |

## pn_reactor()

PN_EXTERN pn_reactor_t* pn_reactor | ( | void |  | ) |

## pn_reactor_acceptor()

PN_EXTERN pn_acceptor_t* pn_reactor_acceptor | ( | pn_reactor_t * | reactor,
|  | const char * | host,
|  | const char * | port,
|  | pn_handler_t * | handler
| ) |  |

## pn_reactor_attachments()

PN_EXTERN pn_record_t* pn_reactor_attachments | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_children()

PN_EXTERN pn_list_t* pn_reactor_children | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_collector()

PN_EXTERN pn_collector_t* pn_reactor_collector | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_connection()

PN_EXTERN pn_connection_t* pn_reactor_connection | ( | pn_reactor_t * | reactor,
|  | pn_handler_t * | handler
| ) |  |

Create an outgoing connection that will be managed by the reactor.

The host address for the connection must be set via pn_reactor_set_connection_host() prior to opening the connection. Typically this can be done by the handler when processing the PN_CONNECTION_INIT event.

Parameters

  [in] | reactor | the reactor that will own the connection.
  [in] | handler | the handler that will process all events generated by this connection.

Returns
  a connection object

Deprecated:
  Use pn_reactor_connection_to_host() instead.

## pn_reactor_connection_to_host()

PN_EXTERN pn_connection_t* pn_reactor_connection_to_host | ( | pn_reactor_t * | reactor,
|  | const char * | host,
|  | const char * | port,
|  | pn_handler_t * | handler
| ) |  |

Create an outgoing connection that will be managed by the reactor.

The reator's pn_iohandler will create a socket connection to the host once the connection is opened.

Parameters

  [in] | reactor | the reactor that will own the connection.
  [in] | host | the address of the remote host. e.g. "localhost"
  [in] | port | the port to connect to. e.g. "5672"
  [in] | handler | the handler that will process all events generated by this connection.

Returns
  a connection object

## pn_reactor_free()

PN_EXTERN void pn_reactor_free | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_get_connection_address()

PN_EXTERN const char* pn_reactor_get_connection_address | ( | pn_reactor_t * | reactor,
|  | pn_connection_t * | connection
| ) |  |

Retrieve the peer host address for a reactor connection.

This may be used to retrieve the host address used by the reactor to establish the outgoing socket connection. In the case of an accepted connection the returned value is the address of the remote.

Note
  Note that the returned address may be in numeric IP format.

The pointer returned by this operation is valid until either the address is changed via pn_reactor_set_connection_host() or the connection object is freed.

Parameters

  [in] | reactor | the reactor that owns the connection.
  [in] | connection | the reactor connection

Returns
  a C string containing the address in URL format or NULL if no address available. pn_url_parse() may be used to create a Proton pn_url_t instance from the returned value.

## pn_reactor_get_global_handler()

PN_EXTERN pn_handler_t* pn_reactor_get_global_handler | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_get_handler()

PN_EXTERN pn_handler_t* pn_reactor_get_handler | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_get_timeout()

PN_EXTERN pn_millis_t pn_reactor_get_timeout | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_io()

PN_EXTERN pn_io_t* pn_reactor_io | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_mark()

PN_EXTERN pn_timestamp_t pn_reactor_mark | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_now()

PN_EXTERN pn_timestamp_t pn_reactor_now | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_process()

PN_EXTERN bool pn_reactor_process | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_quiesced()

PN_EXTERN bool pn_reactor_quiesced | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_run()

PN_EXTERN void pn_reactor_run | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_schedule()

PN_EXTERN pn_task_t* pn_reactor_schedule | ( | pn_reactor_t * | reactor,
|  | int | delay,
|  | pn_handler_t * | handler
| ) |  |

## pn_reactor_selectable()

PN_EXTERN pn_selectable_t* pn_reactor_selectable | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_set_connection_host()

PN_EXTERN void pn_reactor_set_connection_host | ( | pn_reactor_t * | reactor,
|  | pn_connection_t * | connection,
|  | const char * | host,
|  | const char * | port
| ) |  |

Change the host address used by an outgoing reactor connection.

The address is used by the reactor's iohandler to create an outgoing socket connection. This must be set prior to (re)opening the connection.

Parameters

  [in] | reactor | the reactor that owns the connection.
  [in] | connection | the connection created by the reactor.
  [in] | host | the network address or DNS name of the host to connect to.
  [in] | port | the network port to use. Optional - default is "5672"

## pn_reactor_set_global_handler()

PN_EXTERN void pn_reactor_set_global_handler | ( | pn_reactor_t * | reactor,
|  | pn_handler_t * | handler
| ) |  |

## pn_reactor_set_handler()

PN_EXTERN void pn_reactor_set_handler | ( | pn_reactor_t * | reactor,
|  | pn_handler_t * | handler
| ) |  |

## pn_reactor_set_timeout()

PN_EXTERN void pn_reactor_set_timeout | ( | pn_reactor_t * | reactor,
|  | pn_millis_t | timeout
| ) |  |

## pn_reactor_start()

PN_EXTERN void pn_reactor_start | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_stop()

PN_EXTERN void pn_reactor_stop | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_update()

PN_EXTERN void pn_reactor_update | ( | pn_reactor_t * | reactor,
|  | pn_selectable_t * | selectable
| ) |  |

## pn_reactor_wakeup()

PN_EXTERN int pn_reactor_wakeup | ( | pn_reactor_t * | reactor | ) |

## pn_reactor_yield()

PN_EXTERN void pn_reactor_yield | ( | pn_reactor_t * | reactor | ) |

## pn_record_get_handler()

PN_EXTERN pn_handler_t* pn_record_get_handler | ( | pn_record_t * | record | ) |

## pn_record_set_handler()

PN_EXTERN void pn_record_set_handler | ( | pn_record_t * | record,
|  | pn_handler_t * | handler
| ) |  |

## pn_task_attachments()

PN_EXTERN pn_record_t* pn_task_attachments | ( | pn_task_t * | task | ) |

## pn_task_cancel()

PN_EXTERN void pn_task_cancel | ( | pn_task_t * | task | ) |

## pn_timer()

PN_EXTERN pn_timer_t* pn_timer | ( | pn_collector_t * | collector | ) |

## pn_timer_deadline()

PN_EXTERN pn_timestamp_t pn_timer_deadline | ( | pn_timer_t * | timer | ) |

## pn_timer_schedule()

PN_EXTERN pn_task_t* pn_timer_schedule | ( | pn_timer_t * | timer,
|  | pn_timestamp_t | deadline
| ) |  |

## pn_timer_tasks()

PN_EXTERN int pn_timer_tasks | ( | pn_timer_t * | timer | ) |

## pn_timer_tick()

PN_EXTERN void pn_timer_tick | ( | pn_timer_t * | timer,
|  | pn_timestamp_t | now
| ) |  |