shard-crystal-db/spec/support/fibers.cr
Jamie Gaskins 291b65b853
Allow DB::Pool to be used a generic connection pool (#131)
* Allow DB::Pool to be a generic connection pool

* Use fully qualified class name for consistency

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>

* Wrap only the necessary code in an `ensure`

* Add spec for http client pool

* Fix ICE in crystal-sqlite3

Co-authored-by: Brian J. Cardiff <bcardiff@gmail.com>
2020-09-14 10:49:00 -03:00

16 lines
425 B
Crystal

def wait_until_blocked(f : Fiber, timeout = 5.seconds)
now = Time.monotonic
until f.resumable?
Fiber.yield
raise "fiber failed to block within #{timeout}" if (Time.monotonic - now) > timeout
end
end
def wait_until_finished(f : Fiber, timeout = 5.seconds)
now = Time.monotonic
until f.dead?
Fiber.yield
raise "fiber failed to finish within #{timeout}" if (Time.monotonic - now) > timeout
end
end