File: fiber_concurrency.rb

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (24 lines) | stat: -rw-r--r-- 644 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# frozen-string-literal: true
#
# The fiber_concurrency extension changes the default concurrency
# primitive in Sequel to be Fiber.current instead of Thread.current.
# This is the value used in various hash keys to implement safe
# concurrency (thread-safe concurrency by default, fiber-safe
# concurrency with this extension.  It can be enabled via:
#
#   Sequel.extension :fiber_concurrency
#   
# Related module: Sequel::FiberConcurrency

require 'fiber'

module Sequel
  module FiberConcurrency
    # Make the current concurrency primitive be Fiber.current.
    def current
      Fiber.current
    end
  end

  extend FiberConcurrency
end