Skip to content

Commit

Permalink
Test selector allocation/deallocation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 16, 2024
1 parent 0f1d830 commit 48fa5b3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/io/event/selector/allocation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2021-2024, by Samuel Williams.

require "io/event"

IO::Event::Selector.constants.each do |name|
klass = IO::Event::Selector.const_get(name)

describe(klass, unique: name) do
it "can allocate and deallocate multiple times" do
pipes = 1000.times.collect{IO.pipe}

100000.times do
selector = subject.new(Fiber.current)

10.times do
Fiber.new do
selector.io_wait(Fiber.current, pipes.sample[1], IO::WRITABLE)
end.transfer
end

selector.select(0)
ensure
selector&.close
end

GC.start
end
end
end

0 comments on commit 48fa5b3

Please sign in to comment.