Class: Teek::BackgroundNone::BackgroundWork::TaskContext Private

Inherits:
Object
  • Object
show all
Defined in:
lib/teek/background_none.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Synchronous task context - callbacks fire immediately

Instance Method Summary collapse

Constructor Details

#initialize(app, callbacks, message_queue) ⇒ TaskContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of TaskContext.



110
111
112
113
114
115
# File 'lib/teek/background_none.rb', line 110

def initialize(app, callbacks, message_queue)
  @app = app
  @callbacks = callbacks
  @message_queue = message_queue
  @paused = false
end

Instance Method Details

#check_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



121
122
123
124
125
# File 'lib/teek/background_none.rb', line 121

def check_message
  msg = @message_queue.shift
  handle_control_message(msg) if msg
  msg
end

#check_pauseObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



135
136
137
138
139
140
141
# File 'lib/teek/background_none.rb', line 135

def check_pause
  while @paused
    @app.update
    msg = check_message
    break unless @paused
  end
end

#send_message(msg) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



131
132
133
# File 'lib/teek/background_none.rb', line 131

def send_message(msg)
  @callbacks[:message]&.call(msg)
end

#wait_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



127
128
129
# File 'lib/teek/background_none.rb', line 127

def wait_message
  check_message
end

#yield(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



117
118
119
# File 'lib/teek/background_none.rb', line 117

def yield(value)
  @callbacks[:progress]&.call(value)
end