From a11fd9993f1b2acbfc645c426d69eb9d6758cbf0 Mon Sep 17 00:00:00 2001 From: tidwall Date: Mon, 15 Apr 2024 10:00:09 -0700 Subject: [PATCH] Add option to toggle workers This also disables read workers by default --- neco.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/neco.c b/neco.c index f56d647..14521f0 100644 --- a/neco.c +++ b/neco.c @@ -29,6 +29,8 @@ NECO_NOPOOL // Do not use a coroutine and channel pools NECO_USEHEAPSTACK // Allocate stacks on the heap using malloc NECO_NOSIGNALS // Disable signal handling NECO_NOWORKERS // Disable all worker threads, work will run in coroutine +NECO_USEREADWORKERS // Use read workers, disabled by default +NECO_NOWRITEWORKERS // Disable write workers */ // Windows and Webassembly have limited features. @@ -4986,7 +4988,7 @@ static void cowait(int fd, enum evkind kind, int64_t deadline) { // Networking code //////////////////////////////////////////////////////////////////////////////// -#ifndef NECO_NOWORKERS +#if !defined(NECO_NOWORKERS) && defined(NECO_USEREADWORKERS) struct ioread { int fd; @@ -5010,7 +5012,7 @@ static void ioread(void *udata) { static ssize_t read1(int fd, void *data, size_t nbytes) { ssize_t n; - bool nowork = false; + bool nowork = true; #ifdef NECO_TESTING if (neco_fail_read_counter > 0) { nowork = true; @@ -5148,7 +5150,7 @@ static ssize_t write1(int fd, const void *data, size_t nbytes) { #define write2 write1 #endif -#ifndef NECO_NOWORKERS +#if !defined(NECO_NOWORKERS) && !defined(NECO_NOWRITEWORKERS) struct iowrite { int fd; const void *data;