fastcgi++
A C++ FastCGI/Web API
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Fastcgipp::Manager< RequestT > Class Template Reference

General task and protocol management class. More...

#include <fastcgi++/manager.hpp>

Inheritance diagram for Fastcgipp::Manager< RequestT >:
Fastcgipp::Manager_base

Public Member Functions

 Manager (unsigned threads=std::thread::hardware_concurrency())
 Sole constructor. More...
 
void terminate ()
 Call from any thread to terminate the Manager. More...
 
void stop ()
 Call from any thread to stop the Manager. More...
 
void start ()
 Call from any thread to start the Manager. More...
 
void join ()
 Block until a stop() or terminate() is called and completed. More...
 
bool listen ()
 Listen to the default Fastcgi socket. More...
 
bool listen (const char *name, uint32_t permissions=0xffffffffUL, const char *owner=nullptr, const char *group=nullptr)
 Listen to a named socket. More...
 
bool listen (const char *interface, const char *service)
 Listen to a TCP port. More...
 
void push (Protocol::RequestId id, Message &&message)
 Pass a message to a request. More...
 

Static Public Member Functions

static void setupSignals ()
 Configure the handlers for POSIX signals. More...
 

Protected Attributes

Transceiver m_transceiver
 Handles low level communication with the other side. More...
 

Private Member Functions

std::unique_ptr< Request_basemakeRequest (const Protocol::RequestId &id, const Protocol::Role &role, bool kill)
 Make a request object. More...
 

Detailed Description

template<class RequestT>
class Fastcgipp::Manager< RequestT >

General task and protocol management class.

Handles all task and protocol management, creation/destruction of requests and passing of messages to requests. The template argument should be a class type derived from the Request class with at least the response() function defined.

To operate this class you need to do the following:

Template Parameters
RequestTA class type derived from the Request class with at least the Request::response() function defined.
Date
May 13, 2016
Author
Eddie Carle <eddie.nosp@m.@isa.nosp@m.tec.c.nosp@m.a>

Definition at line 282 of file manager.hpp.

Constructor & Destructor Documentation

template<class RequestT>
Fastcgipp::Manager< RequestT >::Manager ( unsigned  threads = std::thread::hardware_concurrency())
inline

Sole constructor.

Parameters
[in]threadsNumber of threads to use for request handling

Definition at line 289 of file manager.hpp.

Member Function Documentation

void Fastcgipp::Manager_base::join ( )
inherited
bool Fastcgipp::Manager_base::listen ( )
inlineinherited

Listen to the default Fastcgi socket.

Calling this simply adds the default socket used on FastCGI applications that are initialized from HTTP servers.

Returns
True on success. False on failure.

Definition at line 124 of file manager.hpp.

References Fastcgipp::Transceiver::listen(), and Fastcgipp::Manager_base::m_transceiver.

bool Fastcgipp::Manager_base::listen ( const char *  name,
uint32_t  permissions = 0xffffffffUL,
const char *  owner = nullptr,
const char *  group = nullptr 
)
inlineinherited

Listen to a named socket.

Listen on a named socket. In the Unix world this would be a path. In the Windows world I have no idea what this would be.

Parameters
[in]nameName of socket (path in Unix world).
[in]permissionsPermissions of socket. If you do not wish to set the permissions, leave it as it's default value of 0xffffffffUL.
[in]ownerOwner (username) of socket. Leave as nullptr if you do not wish to set it.
[in]groupGroup (group name) of socket. Leave as nullptr if you do not wish to set it.
Returns
True on success. False on failure.

Definition at line 144 of file manager.hpp.

References Fastcgipp::Transceiver::listen(), and Fastcgipp::Manager_base::m_transceiver.

bool Fastcgipp::Manager_base::listen ( const char *  interface,
const char *  service 
)
inlineinherited

Listen to a TCP port.

Listen on a specific interface and TCP port.

Parameters
[in]interfaceInterface to listen on. This could be an IP address or a hostname. If you don't want to specify the interface, pass nullptr.
[in]servicePort or service to listen on. This could be a service name, or a string representation of a port number.
Returns
True on success. False on failure.

Definition at line 165 of file manager.hpp.

References Fastcgipp::Transceiver::listen(), Fastcgipp::Manager_base::m_transceiver, Fastcgipp::Manager_base::makeRequest(), and Fastcgipp::Manager_base::push().

template<class RequestT>
std::unique_ptr<Request_base> Fastcgipp::Manager< RequestT >::makeRequest ( const Protocol::RequestId id,
const Protocol::Role role,
bool  kill 
)
inlineprivatevirtual
void Fastcgipp::Manager_base::push ( Protocol::RequestId  id,
Message &&  message 
)
inherited
void Fastcgipp::Manager_base::setupSignals ( )
staticinherited

Configure the handlers for POSIX signals.

By calling this function appropriate handlers will be set up for SIGPIPE, SIGUSR1 and SIGTERM.

See also
signalHandler()

Definition at line 100 of file manager.cpp.

References Fastcgipp::Manager_base::signalHandler().

void Fastcgipp::Manager_base::start ( )
inherited
void Fastcgipp::Manager_base::stop ( )
inherited

Call from any thread to stop the Manager.

This function is intended to be called from a signal handler in the case of of a SIGUSR1. It is similar to terminate() except the Manager will wait until all requests are complete before halting.

See also
join()
setupSignals()
signalHandler()

Definition at line 68 of file manager.cpp.

References Fastcgipp::Manager_base::m_stop, Fastcgipp::Manager_base::m_tasksMutex, Fastcgipp::Manager_base::m_transceiver, Fastcgipp::Manager_base::m_wake, and Fastcgipp::Transceiver::stop().

Referenced by Fastcgipp::Manager_base::signalHandler().

void Fastcgipp::Manager_base::terminate ( )
inherited

Call from any thread to terminate the Manager.

This function is intended to be called from a thread separate from the Manager in order to terminate it. It should also be called by a signal handler in the case of of a SIGTERM. It will force the manager to terminate immediately.

See also
join()
setupSignals()
signalHandler()

Definition at line 60 of file manager.cpp.

References Fastcgipp::Manager_base::m_tasksMutex, Fastcgipp::Manager_base::m_terminate, Fastcgipp::Manager_base::m_transceiver, Fastcgipp::Manager_base::m_wake, and Fastcgipp::Transceiver::terminate().

Referenced by Fastcgipp::Manager_base::signalHandler(), and Fastcgipp::Manager_base::~Manager_base().

Member Data Documentation

Transceiver Fastcgipp::Manager_base::m_transceiver
protectedinherited

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