From 48bf3855a48467579321ba56c3406e574b046638 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 29 Dec 2024 15:34:46 +0100 Subject: [PATCH] ev::newloop: allow user to customize event buffer size Signed-of-by: Drew DeVault --- ev/+linux/loop.ha | 8 +++++--- diff --git a/ev/+linux/loop.ha b/ev/+linux/loop.ha index 145273adf7db6f9b7949c5e73cef130ec32b5e75..d58fd96dc1c706f3c1964b94098db02d69c2888e 100644 --- a/ev/+linux/loop.ha +++ b/ev/+linux/loop.ha @@ -24,7 +24,10 @@ }; // Creates a new event loop. The user must pass the return value to [[finish]] // to free associated resources when done using the loop. -export fn newloop() (loop | errors::error) = { +// +// The optional "events" parameter controls how many events may be pending at +// once. Most applications should not need to configure this parameter. +export fn newloop(events: size = 256) (loop | errors::error) = { const fd = match (rt::epoll_create1(rt::EPOLL_CLOEXEC)) { case let fd: int => yield fd: io::file; @@ -34,13 +37,12 @@ }; return loop { fd = fd, - // XXX: Should the number of events be customizable? events = alloc([rt::epoll_event { events = 0, data = rt::epoll_data { fd = 0, } - }...], 256), + }...], events), dispatch = [], stop = false, }; -- 2.48.1