Sha256: 41479f1e06566d1b8d65bda8e835ece742f37cdffe8a6f0662b64c345b7ba39c

Contents?: true

Size: 564 Bytes

Versions: 4

Compression:

Stored size: 564 Bytes

Contents

module GrpcKit
  class ControlQueue
    def initialize
      @event_stream = Queue.new
    end

    # Be nonblocking
    def pop
      if @event_stream.empty?
        nil
      else
        @event_stream.pop(true)
      end
    rescue ThreadError => _
      nil
    end

    def submit_response(id, headers)
      @event_stream.push([:submit_response, id, headers])
    end

    def submit_headers(id, headers)
      @event_stream.push([:submit_headers, id, headers])
    end

    def resume_data(id)
      @event_stream.push([:resume_data, id])
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
grpc_kit-0.3.3 lib/grpc_kit/control_queue.rb
grpc_kit-0.3.2 lib/grpc_kit/control_queue.rb
grpc_kit-0.3.1 lib/grpc_kit/control_queue.rb
grpc_kit-0.3.0 lib/grpc_kit/control_queue.rb