Archived
1
0

make read buffer size templated

This commit is contained in:
Jeff Becker 2018-05-06 08:17:32 -04:00
parent 242e996ded
commit 9d33a89bc1
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 10 additions and 5 deletions

View File

@ -14,11 +14,12 @@ namespace nntpchan
{
namespace ev
{
template<size_t bufsz>
struct EpollLoop : public Loop
{
size_t conns;
int epollfd;
char readbuf[128];
char readbuf[bufsz];
EpollLoop() : conns(0), epollfd(epoll_create1(EPOLL_CLOEXEC))
{
}

View File

@ -1,14 +1,17 @@
#include <fcntl.h>
constexpr size_t ev_buffsz = 512;
#ifdef __linux__
#include "epoll.hpp"
typedef nntpchan::ev::EpollLoop LoopImpl;
typedef nntpchan::ev::EpollLoop<ev_buffsz> LoopImpl;
#else
#ifdef __freebsd__
#include "kqueue.hpp"
typedef nntpchan::ev::KqueueLoop LoopImpl;
typedef nntpchan::ev::KqueueLoop<ev_buffsz> LoopImpl;
#else
#ifdef __netbsd__
typedef nntpchan::ev::KqueueLoop LoopImpl;
typedef nntpchan::ev::KqueueLoop<ev_buffsz> LoopImpl;
#else
#error "unsupported platform"
#endif

View File

@ -6,11 +6,12 @@ namespace nntpchan
{
namespace ev
{
template<size_t bufsz>
struct KqueueLoop : public Loop
{
int kfd;
size_t conns;
char readbuf[1024];
char readbuf[bufsz];
KqueueLoop() : kfd(kqueue()), conns(0)