5#ifndef BITCOIN_SUPPORT_EVENTS_H
6#define BITCOIN_SUPPORT_EVENTS_H
11#include <event2/event.h>
12#include <event2/http.h>
14#define MAKE_RAII(type) \
16 struct type##_deleter { \
17 void operator()(struct type *ob) { \
22 typedef std::unique_ptr<struct type, type##_deleter> raii_##type
33 throw std::runtime_error(
"cannot create event_base");
58 throw std::runtime_error(
"create connection failed");
raii_evhttp obtain_evhttp(struct event_base *base)
raii_evhttp_request obtain_evhttp_request(void(*cb)(struct evhttp_request *, void *), void *arg)
raii_evhttp_connection obtain_evhttp_connection_base(struct event_base *base, std::string host, uint16_t port)
raii_event obtain_event(struct event_base *base, evutil_socket_t s, short events, event_callback_fn cb, void *arg)
raii_event_base obtain_event_base()
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...