C++ Classes Reference

This section summarizes the classes and templates that are present in the current source tree.

Core Runtime

Server

Server inherits from ASProcessHandler and ClientHandler and coordinates startup, socket setup, signal handling, and the main poll loop.

class Server
void init()
void setupSocket()
void setupPoll()
void ServerLoop()
void acceptClient()
void setupSharedMemory()
static void addChildPID(pid_t)
static void terminateChildren()

setupSharedMemory() currently exists as an empty hook in src/Server.cpp.

Client

Client inherits from HTTPParser and stores the socket file descriptor plus a reusable receive buffer pointer.

class Client
Client(Filedescriptor_t, char*)
bool receiveData()

receiveData() repeatedly reads from the client socket until the kernel buffer is drained, EOF is reached, or a hard receive error occurs.

ClientHandler

ClientHandler owns the active client map and epoll state.

class ClientHandler
typedef std::shared_ptr<Client> ClientRef_t
typedef unordered_map<Filedescriptor_t, ClientRef_t> ClientMap_t
void addClient(const Filedescriptor_t)
void processClients()
void readClientData(const uint16_t)

Configuration and Filesystem

Configuration

Configuration loads config/config.json and maps namespace definitions to runtime objects.

class Configuration
typedef struct NamespaceProps_t
typedef unordered_map<string, NamespaceProps_t> Namespaces_t
void mapStaticFSData()

Filesystem

Filesystem indexes static files and their metadata.

class Filesystem
typedef struct FileProperties_t
typedef vector<string> FilelistPlain_t
typedef unordered_map<string, const FileProperties_t> FileListExtended_t
void initFiles()
void processFileProperties()
FileProperties_t getFilePropertiesByFile(const string &File)
bool checkFileExists(const string &File)
string getFileEtag(const string &File)

Backend Support

ASProcessHandler

ASProcessHandler currently provides the lifecycle interface for backend child processes and the configured interpreter count.

class ASProcessHandler
typedef struct ASProcessHandlerSHMPointer_t
void forkProcessASHandler(ASProcessHandlerSHMPointer_t)
uint getASInterpreterCount()
void setTerminationHandler()
static void terminate(int)
static void registerChildPID(pid_t)

HTTP Library

HTTPParser

HTTPParser is the reusable request parser from lib/http/httpparser.*.

class HTTPParser
typedef unordered_map<string, string> RequestHeader_t
typedef unordered_map<string, string> URLParamMap_t
typedef vector<RequestProperties_t> RequestsMap_t
void appendBuffer(const char*, const uint16_t)
RequestsMap_t getRequests()
RequestsMapPtr_t getRequestsPtr()

HTTPMessageGenerator

The message-generator component is implemented by HTTPGenerator.

class HTTPGenerator
typedef unordered_map<HeaderID_t, HeaderValue_t> ResponseHeader_t
void MsgReset()
void MsgSetStatus(const uint16_t, const string&)
void MsgAddHeader(const HeaderID_t, const HeaderValue_t)
void MsgAddDateHeader()
void MsgSetBodyRef(const unsigned char*, const unsigned int)
void MsgGenerate()
SendMetadata_t MsgGetSendMetadata()
bool MsgUpdateSendMetadata(ssize_t)

Utilities

MemoryManager

MemoryManager<T> provides aligned segmented storage used by the runtime for reusable buffers.

template<class T>
class MemoryManager
MemoryManager(uint16_t SegmentCount, uint16_t SegmentSize)
T *getNextMemPointer()
T *getMemBaseAddress()

SHMVector

SHMVector<T> in src/SHMVector.hpp is the shared-memory-safe vector implementation.

template<typename T>
class SHMVector
SHMVector(size_t segment_size_bytes, void *shared_memory_ptr, size_t shared_memory_size)
void reserve(size_t element_count)
void push_back(const T &element)
T &at(size_t index)
size_t size() const
size_t capacity() const
void eraseAt(size_t index)
T getNextElement()

CPU

CPU contains CPU affinity helper methods used by process-oriented runtime code.

class CPU
void bindToCPU(int core)
void bindToCPUs(std::vector<int> cores)

Vector

Vector contains custom helper functionality for vector-style containers.

class Vector
void multiErase(std::vector<size_t> indices)