Class: GrpcKit::Session::ControlQueue
- Inherits:
-
Object
- Object
- GrpcKit::Session::ControlQueue
- Defined in:
- lib/grpc_kit/session/control_queue.rb
Instance Method Summary collapse
-
#initialize(waker: proc { }) ⇒ ControlQueue
constructor
A new instance of ControlQueue.
-
#pop ⇒ Object
Be nonblocking.
- #resume_data(id) ⇒ Object
- #submit_headers(id, headers) ⇒ Object
- #submit_response(id, headers) ⇒ Object
Constructor Details
#initialize(waker: proc { }) ⇒ ControlQueue
Returns a new instance of ControlQueue.
6 7 8 9 |
# File 'lib/grpc_kit/session/control_queue.rb', line 6 def initialize(waker: proc { }) @event_stream = Queue.new @waker = waker end |
Instance Method Details
#pop ⇒ Object
Be nonblocking
12 13 14 15 16 17 18 19 20 |
# File 'lib/grpc_kit/session/control_queue.rb', line 12 def pop if @event_stream.empty? nil else @event_stream.pop(true) end rescue ThreadError => _ nil end |
#resume_data(id) ⇒ Object
32 33 34 35 |
# File 'lib/grpc_kit/session/control_queue.rb', line 32 def resume_data(id) @event_stream.push([:resume_data, id]) @waker.call(:submit_response) end |
#submit_headers(id, headers) ⇒ Object
27 28 29 30 |
# File 'lib/grpc_kit/session/control_queue.rb', line 27 def submit_headers(id, headers) @event_stream.push([:submit_headers, id, headers]) @waker.call(:submit_headers) end |
#submit_response(id, headers) ⇒ Object
22 23 24 25 |
# File 'lib/grpc_kit/session/control_queue.rb', line 22 def submit_response(id, headers) @event_stream.push([:submit_response, id, headers]) @waker.call(:submit_response) end |