Sha256: fca00f7624c53a97cc7f8b5a6453ff4cd98ee3c92afdf9373a7dd4155004b3d2

Contents?: true

Size: 941 Bytes

Versions: 8

Compression:

Stored size: 941 Bytes

Contents

module Steep
  module Server
    # DelayQueue provides a queue that delays running given job
    #
    # 1. The `delay` is specific to a DelayQueue instance, not job specific
    # 2. It executes only the last job
    #
    # ```ruby
    # queue = DelayQueue.new(delay: 0.5)
    # queue.execute { pp 1 }
    # queue.execute { pp 2 }
    # queue.execute { pp 3 }
    #
    # # => Will print only `3`, and the jobs printing `1` and `2` will be discarded
    # ```
    #
    # The job will run on `#thread`.
    #
    class DelayQueue
      attr_reader delay: Float

      attr_reader thread: Thread

      attr_reader queue: Thread::Queue

      attr_reader last_task: Proc

      def initialize: (delay: Float) -> void

      # The `#execute` method is not thread safe
      #
      # You should synchronize yourself if you want to call the method from multiple threads.
      #
      def execute: () { () -> void } -> void
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
steep-1.7.0.dev.3 sig/steep/server/delay_queue.rbs
steep-1.7.0.dev.2 sig/steep/server/delay_queue.rbs
steep-1.7.0.dev.1 sig/steep/server/delay_queue.rbs
steep-1.6.0 sig/steep/server/delay_queue.rbs
steep-1.6.0.pre.4 sig/steep/server/delay_queue.rbs
steep-1.6.0.pre.3 sig/steep/server/delay_queue.rbs
steep-1.6.0.pre.2 sig/steep/server/delay_queue.rbs
steep-1.6.0.pre.1 sig/steep/server/delay_queue.rbs