mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
Merge pull request #124 from crystal-lang/crystal/0.34.0
Crystal 0.34.0 support
This commit is contained in:
commit
7543908733
3 changed files with 34 additions and 17 deletions
|
@ -246,6 +246,8 @@ describe DummyDriver do
|
|||
rs.read(Int64, Int64).should eq({3i64, 4i64})
|
||||
when 1
|
||||
rs.read(Int64, Int64).should eq({1i64, 2i64})
|
||||
else
|
||||
raise "unreachable"
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
|
|
@ -206,25 +206,38 @@ module DB
|
|||
@idle.first?
|
||||
end
|
||||
|
||||
private def wait_for_available
|
||||
timeout = TimeoutHelper.new(@checkout_timeout.to_f64)
|
||||
sync_inc_waiting_resource
|
||||
{% if compare_versions(Crystal::VERSION, "0.34.0-0") > 0 %}
|
||||
private def wait_for_available
|
||||
sync_inc_waiting_resource
|
||||
|
||||
timeout.start
|
||||
|
||||
# TODO update to select keyword for crystal 0.19
|
||||
index, _ = Channel.select(@availability_channel.receive_select_action, timeout.receive_select_action)
|
||||
case index
|
||||
when 0
|
||||
timeout.cancel
|
||||
sync_dec_waiting_resource
|
||||
when 1
|
||||
sync_dec_waiting_resource
|
||||
raise DB::PoolTimeout.new
|
||||
else
|
||||
raise DB::Error.new
|
||||
select
|
||||
when @availability_channel.receive
|
||||
sync_dec_waiting_resource
|
||||
when timeout(@checkout_timeout.seconds)
|
||||
sync_dec_waiting_resource
|
||||
raise DB::PoolTimeout.new
|
||||
end
|
||||
end
|
||||
end
|
||||
{% else %}
|
||||
private def wait_for_available
|
||||
timeout = TimeoutHelper.new(@checkout_timeout.to_f64)
|
||||
sync_inc_waiting_resource
|
||||
|
||||
timeout.start
|
||||
|
||||
index, _ = Channel.select(@availability_channel.receive_select_action, timeout.receive_select_action)
|
||||
case index
|
||||
when 0
|
||||
timeout.cancel
|
||||
sync_dec_waiting_resource
|
||||
when 1
|
||||
sync_dec_waiting_resource
|
||||
raise DB::PoolTimeout.new
|
||||
else
|
||||
raise DB::Error.new
|
||||
end
|
||||
end
|
||||
{% end %}
|
||||
|
||||
private def sync_inc_waiting_resource
|
||||
sync { @waiting_resource += 1 }
|
||||
|
|
|
@ -505,6 +505,8 @@ module DB
|
|||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
raise "Invalid prepared value. Allowed values are :both and :default"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue