diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-11 15:04:03 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-11 15:04:03 +0100 |
commit | 27a47bc9b7ba2fa0e2134bfd14565f11d94289fc (patch) | |
tree | 9ab2a2deb1a900912fda2ad5860818cefc418983 /src/loader/loaderhandle.nim | |
parent | b36116d9e7004282803070877278cb10fbdfae57 (diff) | |
download | chawan-27a47bc9b7ba2fa0e2134bfd14565f11d94289fc.tar.gz |
loader: significantly more efficient loading
The previous version was running the processor on 100% because select would immediately return for writes even when no buffers to send were available. (This has been the case since I added asynchronous sending, but the previous commit put the console buffer's fd in loader too and that made the problem quite obvious.)
Diffstat (limited to 'src/loader/loaderhandle.nim')
-rw-r--r-- | src/loader/loaderhandle.nim | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/loader/loaderhandle.nim b/src/loader/loaderhandle.nim index 7f583d2b..579c553d 100644 --- a/src/loader/loaderhandle.nim +++ b/src/loader/loaderhandle.nim @@ -29,6 +29,7 @@ type sostream*: PosixStream # saved ostream when redirected clientFd*: int clientPid*: int + registered*: bool LoaderHandle* = ref object # Stream for taking input @@ -86,12 +87,11 @@ proc newLoaderBuffer*(): LoaderBuffer = buffer.len = 0 return buffer -proc addBuffer*(handle: LoaderHandle, buffer: LoaderBuffer) = - for output in handle.outputs.mitems: - if output.currentBuffer == nil: - output.currentBuffer = buffer - else: - output.buffers.addLast(buffer) +proc addBuffer*(output: OutputHandle, buffer: LoaderBuffer) = + if output.currentBuffer == nil: + output.currentBuffer = buffer + else: + output.buffers.addLast(buffer) proc bufferCleared*(output: OutputHandle) = assert output.currentBuffer != nil |