29 #ifndef FASTCGIPP_MANAGER_HPP 30 #define FASTCGIPP_MANAGER_HPP 37 #include <shared_mutex> 146 uint32_t permissions = 0xffffffffUL,
147 const char* owner =
nullptr,
148 const char* group =
nullptr)
166 const char* interface,
235 #if FASTCGIPP_LOG_LEVEL > 3 236 std::atomic_ullong m_requestCount;
240 size_t m_maxRequests;
243 std::atomic_ullong m_managementRecordCount;
246 std::atomic_ullong m_badSocketMessageCount;
249 std::atomic_ullong m_badSocketKillCount;
252 std::atomic_ullong m_messageCount;
255 unsigned m_activeThreads;
258 unsigned m_maxActiveThreads;
289 Manager(
unsigned threads = std::thread::hardware_concurrency()):
300 using namespace std::placeholders;
302 std::unique_ptr<Request_base> request(
new RequestT);
303 static_cast<RequestT&
>(*request).configure(
std::vector< std::thread > m_threads
Threads our manager is running in.
Topmost namespace for the fastcgi++ library.
void send(const Socket &socket, Block &&data, bool kill)
Queue up a block of data for transmission.
bool m_terminate
True when the manager should be terminating.
Transceiver m_transceiver
Handles low level communication with the other side.
std::mutex m_startStopMutex
Thread safe starting and stopping.
General task and protocol management class base.
static void setupSignals()
Configure the handlers for POSIX signals.
General task and protocol management class.
void handler()
General handling function to have it's own thread.
Data structure used to pass messages to requests.
virtual std::unique_ptr< Request_base > makeRequest(const Protocol::RequestId &id, const Protocol::Role &role, bool kill)=0
Make a request object.
std::unique_ptr< Request_base > makeRequest(const Protocol::RequestId &id, const Protocol::Role &role, bool kill)
Make a request object.
void join()
Block until a stop() or terminate() is called and completed.
std::queue< std::pair< Message, Socket > > m_messages
Local messages.
bool m_stop
True when the manager should be stopping.
Declares everything for relating to the FastCGI protocol itself.
std::mutex mutex
Thread safe the logging mechanism.
std::mutex m_messagesMutex
Thread safe our local messages.
std::condition_variable m_wake
Condition variable to wake handler() threads up.
void start()
Call from any thread to start the Manager.
static void signalHandler(int signum)
General function to handler POSIX signals.
void localHandler()
Handles management messages.
A unique identifier for each FastCGI request.
Handles low level communication with "the other side".
void push(Protocol::RequestId id, Message &&message)
Pass a message to a request.
std::mutex m_tasksMutex
Thread safe our tasks.
bool listen()
Listen to the default Fastcgi socket.
std::shared_timed_mutex m_requestsMutex
Thread safe our requests.
Manager(unsigned threads=std::thread::hardware_concurrency())
Sole constructor.
Declares the Request class.
void terminate()
Call from any thread to terminate the Manager.
Declares the Fastcgipp::Transceiver class.
Manager_base(unsigned threads)
Sole constructor.
void stop()
Call from any thread to stop the Manager.
bool listen()
Listen to the default Fastcgi socket.
Protocol::Requests< std::unique_ptr< Request_base > > m_requests
An associative container for our requests.
static Manager_base * instance
Pointer to the Manager object.
bool listen(const char *interface, const char *service)
Listen to a TCP port.
std::queue< Protocol::RequestId > m_tasks
Queue for pending tasks.
std::map< RequestId, T, RequestId::Less > Requests
A simple associative container that indexes with RequestId.
Role
Defines the possible roles a FastCGI application may play.
bool listen(const char *name, uint32_t permissions=0xffffffffUL, const char *owner=nullptr, const char *group=nullptr)
Listen to a named socket.