make read buffer size templated
This commit is contained in:
parent
242e996ded
commit
9d33a89bc1
@ -14,11 +14,12 @@ namespace nntpchan
|
|||||||
{
|
{
|
||||||
namespace ev
|
namespace ev
|
||||||
{
|
{
|
||||||
|
template<size_t bufsz>
|
||||||
struct EpollLoop : public Loop
|
struct EpollLoop : public Loop
|
||||||
{
|
{
|
||||||
size_t conns;
|
size_t conns;
|
||||||
int epollfd;
|
int epollfd;
|
||||||
char readbuf[128];
|
char readbuf[bufsz];
|
||||||
EpollLoop() : conns(0), epollfd(epoll_create1(EPOLL_CLOEXEC))
|
EpollLoop() : conns(0), epollfd(epoll_create1(EPOLL_CLOEXEC))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
constexpr size_t ev_buffsz = 512;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include "epoll.hpp"
|
#include "epoll.hpp"
|
||||||
typedef nntpchan::ev::EpollLoop LoopImpl;
|
typedef nntpchan::ev::EpollLoop<ev_buffsz> LoopImpl;
|
||||||
#else
|
#else
|
||||||
#ifdef __freebsd__
|
#ifdef __freebsd__
|
||||||
#include "kqueue.hpp"
|
#include "kqueue.hpp"
|
||||||
typedef nntpchan::ev::KqueueLoop LoopImpl;
|
typedef nntpchan::ev::KqueueLoop<ev_buffsz> LoopImpl;
|
||||||
#else
|
#else
|
||||||
#ifdef __netbsd__
|
#ifdef __netbsd__
|
||||||
typedef nntpchan::ev::KqueueLoop LoopImpl;
|
typedef nntpchan::ev::KqueueLoop<ev_buffsz> LoopImpl;
|
||||||
#else
|
#else
|
||||||
#error "unsupported platform"
|
#error "unsupported platform"
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,11 +6,12 @@ namespace nntpchan
|
|||||||
{
|
{
|
||||||
namespace ev
|
namespace ev
|
||||||
{
|
{
|
||||||
|
template<size_t bufsz>
|
||||||
struct KqueueLoop : public Loop
|
struct KqueueLoop : public Loop
|
||||||
{
|
{
|
||||||
int kfd;
|
int kfd;
|
||||||
size_t conns;
|
size_t conns;
|
||||||
char readbuf[1024];
|
char readbuf[bufsz];
|
||||||
|
|
||||||
|
|
||||||
KqueueLoop() : kfd(kqueue()), conns(0)
|
KqueueLoop() : kfd(kqueue()), conns(0)
|
||||||
|
Reference in New Issue
Block a user