1 #ifndef _STREAM_HANDLER_H 2 #define _STREAM_HANDLER_H 14 #include <condition_variable> 17 #include <sys/epoll.h> 18 #include <reading_stream.h> 20 #define MAX_EVENTS 40 // Number of epoll events in one epoll_wait call 21 #define RDS_BLOCK 10000 // Number of readings to insert in each call to the storage plugin 22 #define BLOCK_POOL_SIZES 512 // Increments of block sizes in a block pool 37 uint32_t create(
int epollfd, uint32_t *token);
38 void handleEvent(
int epollfd,
StorageApi *api, uint32_t events);
48 MemoryPool(
size_t blkIncr) : m_blkIncr(blkIncr) {};
50 void *allocate(
size_t size);
51 void release(
void *handle);
53 size_t rndSize(
size_t size)
55 return m_blkIncr * ((size + m_blkIncr - 1)
58 void createPool(
size_t size);
59 void growPool(std::vector<void *>*,
size_t);
61 std::map<size_t, std::vector<void *>* >
64 void setNonBlocking(
int fd);
65 unsigned int available(
int fd);
66 void queueInsert(
StorageApi *api,
unsigned int nReadings,
bool commit);
68 enum { Closed, Listen, AwaitingToken, Connected }
74 enum { BlkHdr, RdHdr, RdBody }
83 MemoryPool *m_blockPool;
84 std::string m_lastAsset;
88 std::thread m_handlerThread;
90 std::condition_variable m_streamsCV;
91 std::mutex m_streamsMutex;
92 std::vector<Stream *> m_streams;
Definition: stream_handler.h:26
uint32_t createStream(uint32_t *token)
Create a new stream and add it to the epoll mechanism for the stream handler.
Definition: stream_handler.cpp:108
~StreamHandler()
Destructor for the StreamHandler.
Definition: stream_handler.cpp:51
StreamHandler(StorageApi *)
Constructor for the StreamHandler class.
Definition: stream_handler.cpp:40
Definition: reading_stream.h:42
void handler()
The handler method for the stream handler.
Definition: stream_handler.cpp:63
The Storage API class - this class is responsible for the registration of all API entry points in the...
Definition: storage_api.h:84