Class: Synchrotron::Stream
- Inherits:
-
Object
- Object
- Synchrotron::Stream
- Defined in:
- lib/synchrotron/stream.rb
Instance Method Summary collapse
-
#initialize(paths, callback, since = OSX::KFSEventStreamEventIdSinceNow) ⇒ Stream
constructor
A new instance of Stream.
- #release ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(paths, callback, since = OSX::KFSEventStreamEventIdSinceNow) ⇒ Stream
Returns a new instance of Stream.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/synchrotron/stream.rb', line 3 def initialize(paths, callback, since = OSX::KFSEventStreamEventIdSinceNow) @log = Synchrotron.log @started = false @stream = OSX.FSEventStreamCreate(nil, callback, nil, paths.to_a, since, 0.5, 0) raise "failed to create FSEventStream" unless check_stream OSX.FSEventStreamScheduleWithRunLoop(@stream, OSX.CFRunLoopGetCurrent(), OSX::KCFRunLoopDefaultMode) end |
Instance Method Details
#release ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/synchrotron/stream.rb', line 14 def release stop OSX.FSEventStreamInvalidate(@stream) OSX.FSEventStreamRelease(@stream) @log.debug "FSEventStream released" end |
#start ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/synchrotron/stream.rb', line 22 def start return if @started raise "failed to start FSEventStream" unless OSX.FSEventStreamStart(@stream) @started = true @log.debug "FSEventStream started" end |
#stop ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/synchrotron/stream.rb', line 30 def stop return unless @started OSX.FSEventStreamStop(@stream) @started = false @log.debug "FSEventStream stopped" end |