Crow  1.0
A C++ microframework for the web
crow::Server< Handler, Adaptor, Middlewares > Class Template Reference
Collaboration diagram for crow::Server< Handler, Adaptor, Middlewares >:

Public Member Functions

 Server (Handler *handler, std::string bindaddr, uint16_t port, std::string server_name=std::string("Crow/")+VERSION, std::tuple< Middlewares... > *middlewares=nullptr, uint16_t concurrency=1, uint8_t timeout=5, typename Adaptor::context *adaptor_ctx=nullptr)
 
void set_tick_function (std::chrono::milliseconds d, std::function< void()> f)
 
void on_tick ()
 
void run ()
 
void stop ()
 
void signal_clear ()
 
void signal_add (int signal_number)
 

Private Member Functions

uint16_t pick_io_service_idx ()
 
void do_accept ()
 

Private Attributes

asio::io_service io_service_
 
std::vector< std::unique_ptr< asio::io_service > > io_service_pool_
 
std::vector< detail::task_timer * > task_timer_pool_
 
std::vector< std::function< std::string()> > get_cached_date_str_pool_
 
tcp::acceptor acceptor_
 
boost::asio::signal_set signals_
 
boost::asio::deadline_timer tick_timer_
 
Handler * handler_
 
uint16_t concurrency_ {2}
 
std::uint8_t timeout_
 
std::string server_name_
 
uint16_t port_
 
std::string bindaddr_
 
std::vector< std::atomic< unsigned int > > task_queue_length_pool_
 
std::chrono::milliseconds tick_interval_
 
std::function< void()> tick_function_
 
std::tuple< Middlewares... > * middlewares_
 
Adaptor::context * adaptor_ctx_
 

Constructor & Destructor Documentation

◆ Server()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
crow::Server< Handler, Adaptor, Middlewares >::Server ( Handler *  handler,
std::string  bindaddr,
uint16_t  port,
std::string  server_name = std::string("Crow/") + VERSION,
std::tuple< Middlewares... > *  middlewares = nullptr,
uint16_t  concurrency = 1,
uint8_t  timeout = 5,
typename Adaptor::context *  adaptor_ctx = nullptr 
)
inline

Member Function Documentation

◆ set_tick_function()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::set_tick_function ( std::chrono::milliseconds  d,
std::function< void()>  f 
)
inline

◆ on_tick()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::on_tick ( )
inline

◆ run()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::run ( )
inline
Here is the call graph for this function:

◆ stop()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::stop ( )
inline

◆ signal_clear()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::signal_clear ( )
inline

◆ signal_add()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::signal_add ( int  signal_number)
inline

◆ pick_io_service_idx()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
uint16_t crow::Server< Handler, Adaptor, Middlewares >::pick_io_service_idx ( )
inlineprivate

◆ do_accept()

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
void crow::Server< Handler, Adaptor, Middlewares >::do_accept ( )
inlineprivate

Member Data Documentation

◆ io_service_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
asio::io_service crow::Server< Handler, Adaptor, Middlewares >::io_service_
private

◆ io_service_pool_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::vector<std::unique_ptr<asio::io_service> > crow::Server< Handler, Adaptor, Middlewares >::io_service_pool_
private

◆ task_timer_pool_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::vector<detail::task_timer*> crow::Server< Handler, Adaptor, Middlewares >::task_timer_pool_
private

◆ get_cached_date_str_pool_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::vector<std::function<std::string()> > crow::Server< Handler, Adaptor, Middlewares >::get_cached_date_str_pool_
private

◆ acceptor_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
tcp::acceptor crow::Server< Handler, Adaptor, Middlewares >::acceptor_
private

◆ signals_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
boost::asio::signal_set crow::Server< Handler, Adaptor, Middlewares >::signals_
private

◆ tick_timer_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
boost::asio::deadline_timer crow::Server< Handler, Adaptor, Middlewares >::tick_timer_
private

◆ handler_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
Handler* crow::Server< Handler, Adaptor, Middlewares >::handler_
private

◆ concurrency_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
uint16_t crow::Server< Handler, Adaptor, Middlewares >::concurrency_ {2}
private

◆ timeout_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::uint8_t crow::Server< Handler, Adaptor, Middlewares >::timeout_
private

◆ server_name_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::string crow::Server< Handler, Adaptor, Middlewares >::server_name_
private

◆ port_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
uint16_t crow::Server< Handler, Adaptor, Middlewares >::port_
private

◆ bindaddr_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::string crow::Server< Handler, Adaptor, Middlewares >::bindaddr_
private

◆ task_queue_length_pool_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::vector<std::atomic<unsigned int> > crow::Server< Handler, Adaptor, Middlewares >::task_queue_length_pool_
private

◆ tick_interval_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::chrono::milliseconds crow::Server< Handler, Adaptor, Middlewares >::tick_interval_
private

◆ tick_function_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::function<void()> crow::Server< Handler, Adaptor, Middlewares >::tick_function_
private

◆ middlewares_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
std::tuple<Middlewares...>* crow::Server< Handler, Adaptor, Middlewares >::middlewares_
private

◆ adaptor_ctx_

template<typename Handler , typename Adaptor = SocketAdaptor, typename... Middlewares>
Adaptor::context* crow::Server< Handler, Adaptor, Middlewares >::adaptor_ctx_
private

The documentation for this class was generated from the following file: