Class: OpenC3::Schedule
- Defined in:
- lib/openc3/microservices/timeline_microservice.rb
Overview
Shared between the monitor thread and the manager thread to share the planned activities. This should remain a thread safe implementation.
Instance Method Summary collapse
- #activities ⇒ Object
- #add_activity(input_activity) ⇒ Object
-
#initialize(name) ⇒ Schedule
constructor
A new instance of Schedule.
- #not_queued?(start) ⇒ Boolean
- #remove_activity(input_activity) ⇒ Object
- #update(input_activities) ⇒ Object
Constructor Details
Instance Method Details
#activities ⇒ Object
181 182 183 184 185 |
# File 'lib/openc3/microservices/timeline_microservice.rb', line 181 def activities @activities_mutex.synchronize do return @activities.dup end end |
#add_activity(input_activity) ⇒ Object
193 194 195 196 197 198 199 |
# File 'lib/openc3/microservices/timeline_microservice.rb', line 193 def add_activity(input_activity) @activities_mutex.synchronize do if @activities.find { |x| x.start == input_activity.start }.nil? @activities << input_activity end end end |
#not_queued?(start) ⇒ Boolean
173 174 175 176 177 178 179 |
# File 'lib/openc3/microservices/timeline_microservice.rb', line 173 def not_queued?(start) return false if @queue.index(start) @queue[@index] = start @index = @index + 1 >= @size ? 0 : @index + 1 return true end |
#remove_activity(input_activity) ⇒ Object
201 202 203 204 205 |
# File 'lib/openc3/microservices/timeline_microservice.rb', line 201 def remove_activity(input_activity) @activities_mutex.synchronize do @activities.delete_if { |h| h.start == input_activity.start } end end |
#update(input_activities) ⇒ Object
187 188 189 190 191 |
# File 'lib/openc3/microservices/timeline_microservice.rb', line 187 def update(input_activities) @activities_mutex.synchronize do @activities = input_activities.dup end end |