Module: Systemd::Journal::Waitable
- Included in:
- Systemd::Journal
- Defined in:
- lib/systemd/journal/waitable.rb
Constant Summary collapse
- IS_JRUBY =
(RUBY_ENGINE == 'jruby')
Instance Method Summary collapse
-
#wait(timeout_usec = -1,, opts = {}) ⇒ Nil, Symbol
Block until the journal is changed.
-
#wait_select_reliable? ⇒ Boolean
Determine if calls to #wait with ‘select: true` will reliably wake when a change occurs.
-
#watch ⇒ Object
Block and wait for new entries to be appended to the journal.
Instance Method Details
#wait(timeout_usec = -1,, opts = {}) ⇒ Nil, Symbol
Block until the journal is changed.
18 19 20 21 22 23 24 25 26 |
# File 'lib/systemd/journal/waitable.rb', line 18 def wait(timeout_usec = -1, opts = {}) if opts[:select] && !IS_JRUBY wait_select(timeout_usec) else rc = Native.sd_journal_wait(@ptr, timeout_usec) raise JournalError, rc if rc.is_a?(Integer) && rc < 0 rc == :nop ? nil : rc end end |
#wait_select_reliable? ⇒ Boolean
32 33 34 |
# File 'lib/systemd/journal/waitable.rb', line 32 def wait_select_reliable? Native.sd_journal_reliable_fd(@ptr) > 0 end |
#watch ⇒ Object
Block and wait for new entries to be appended to the journal. When new entries are written, yields them in turn. Note that this function does not automatically seek to the end of the journal prior to waiting. This method Does not return.
46 47 48 |
# File 'lib/systemd/journal/waitable.rb', line 46 def watch loop { (yield current_entry while move_next) if wait } end |