Module: Gtk
- Defined in:
- lib/gnms.rb,
lib/gui/widgets.rb
Defined Under Namespace
Classes: CList, ImageComboList
Constant Summary
collapse
- PENDING_CALLS_MUTEX =
Thread-safety stuff. Loosely based on booh, by Guillaume Cottenceau.
Mutex.new
- PENDING_CALLS =
[]
Class Method Summary
collapse
Class Method Details
.init_thread_protect ⇒ Object
284
285
286
287
288
289
290
291
292
293
294
|
# File 'lib/gnms.rb', line 284
def self.init_thread_protect
Gtk.timeout_add(100) do
PENDING_CALLS_MUTEX.synchronize do
for closure in PENDING_CALLS
closure.call
end
PENDING_CALLS.clear
end
true
end
end
|
.thread_protect(&proc) ⇒ Object
264
265
266
267
268
269
270
271
272
|
# File 'lib/gnms.rb', line 264
def self.thread_protect(&proc)
if Thread.current == Thread.main
proc.call
else
PENDING_CALLS_MUTEX.synchronize do
PENDING_CALLS << proc
end
end
end
|