-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extracts the undocumented `Fiber::Waiting` struct from `WaitGroup` that acts as the node in a linked list, replacing a `Deque` to store the waiting fibers. The flat array doesn't have much impact on performance: we only reach the head or the tail once to dequeue/dequeue one fiber at a time. This however spares a number of GC allocations since the Deque has to be allocated plus its buffer that will have to be reallocated sometimes (and will only ever grow, never shrink).
- Loading branch information
1 parent
2458e35
commit 5b20837
Showing
3 changed files
with
27 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "crystal/pointer_linked_list" | ||
|
||
class Fiber | ||
# :nodoc: | ||
struct PointerLinkedListNode | ||
include Crystal::PointerLinkedList::Node | ||
|
||
def initialize(@fiber : Fiber) | ||
end | ||
|
||
def enqueue : Nil | ||
@fiber.enqueue | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters