Sha256: 20bbc715699d342d3b6148a3ba600296fefbe9089c6b1044de33f82ea1ab25a7
Contents?: true
Size: 704 Bytes
Versions: 3
Compression:
Stored size: 704 Bytes
Contents
module Space module Events class Sources attr_reader :events, :sources def initialize(events) @events = events @sources = [] end def registered register(Thread.current.object_id) yield.tap do unregister(Thread.current.object_id) end end private def register(source) Thread.exclusive do events.notify(:start) if sources.empty? sources << source end end def unregister(source) Thread.exclusive do sources.delete(source) events.notify(:finish) if sources.empty? end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
space-0.0.9 | lib/space/events/sources.rb |
space-0.0.8 | lib/space/events/sources.rb |
space-0.0.7 | lib/space/events/sources.rb |