diff --git a/CHANGELOG.md b/CHANGELOG.md index 64bd2d2..0777342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [Unreleased] - + +### Fixed +- Replace `Fiber.yield` with `sleep 1.microsecond` in loops to reduce CPU load + ## [1.0.0] - 2023-05-29 ### Added diff --git a/src/pond.cr b/src/pond.cr index ef198e5..bb2057d 100644 --- a/src/pond.cr +++ b/src/pond.cr @@ -42,7 +42,7 @@ class Pond return unless @done == false until size == 0 - Fiber.yield + sleep 1.microsecond end sync do @@ -51,7 +51,7 @@ class Pond end until @done - Fiber.yield + sleep 1.microsecond end end @@ -73,7 +73,7 @@ class Pond spawn do until @done.nil? sync { @fibers.reject!(&.dead?) } - Fiber.yield + sleep 1.microsecond end sync do