Class: Hyalite::Updates
Defined Under Namespace
Classes: NestedUpdate, UpdateQueueing
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Updates.
Instance Attribute Details
#reconcile_transaction ⇒ Object
Returns the value of attribute reconcile_transaction.
40
41
42
|
# File 'lib/hyalite/updates.rb', line 40
def reconcile_transaction
@reconcile_transaction
end
|
Instance Method Details
#asap(&callback) ⇒ Object
116
117
118
119
|
# File 'lib/hyalite/updates.rb', line 116
def asap(&callback)
@asap_callback_queue.enqueue(&callback)
@asap_enqueued = true
end
|
#batched_updates ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/hyalite/updates.rb', line 65
def batched_updates
already_batching_updates = @is_batching_updates
@is_batching_updates = true
if already_batching_updates
yield
else
transaction = Transaction.new do
flush_batched_updates
@is_batching_updates = false
end
transaction.perform do
yield
end
end
end
|
#enqueue_update(component) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/hyalite/updates.rb', line 55
def enqueue_update(component)
unless @is_batching_updates
batched_updates do
enqueue_update(component)
end
end
@dirty_components << component
end
|
#flush_batched_updates ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/hyalite/updates.rb', line 85
def flush_batched_updates
while @dirty_components.length > 0 || @asap_enqueued
if @dirty_components.length > 0
@flush_transaction.perform do |transaction|
run_batched_updates(transaction)
end
end
if @asap_enqueued
@asap_enqueued = false
@asap_callback_queue.notify_all
next
end
end
end
|
#mount_ready ⇒ Object
121
122
123
|
# File 'lib/hyalite/updates.rb', line 121
def mount_ready
@reconcile_transaction.mount_ready
end
|
#run_batched_updates(transaction) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/hyalite/updates.rb', line 101
def run_batched_updates(transaction)
@dirty_components.sort{|c1, c2| c1.mount_order <=> c2.mount_order}.each do |component|
callbacks = component.pending_callbacks
component.pending_callbacks = nil
Reconciler.perform_update_if_necessary(component, @reconcile_transaction.mount_ready)
if callbacks
callbacks.each do |callback|
@callback_queue.enqueue(callback)
end
end
end
end
|