+ below. <function>sd_journal_get_timeout()</function>
+ will ensure in these cases that wake-ups happen
+ frequently enough for changes to be noticed, although
+ with a certain latency.</para>
+
+ <para><function>sd_journal_get_events()</function>
+ will return the <function>poll()</function> mask to
+ wait for. This function will return a combination of
+ <constant>POLLIN</constant> and
+ <constant>POLLOUT</constant> and similar to fill into
+ the <literal>.events</literal> field of
+ <varname>struct pollfd</varname>.</para>
+
+ <para><function>sd_journal_get_timeout()</function>
+ will return a timeout value for usage in
+ <function>poll()</function>. This returns a value in
+ microseconds since the epoch of
+ <constant>CLOCK_MONOTONIC</constant> for timing out
+ <function>poll()</function> in
+ <varname>timeout_usec</varname>. See
+ <citerefentry><refentrytitle>clock_gettime</refentrytitle><manvolnum>2</manvolnum></citerefentry>
+ for details about
+ <constant>CLOCK_MONOTONIC</constant>. If there is no
+ timeout to wait for, this will fill in
+ <constant>(uint64_t) -1</constant> instead. Note that
+ <function>poll()</function> takes a relative timeout
+ in milliseconds rather than an absolute timeout in
+ microseconds. To convert the absolute 'us' timeout
+ into relative 'ms', use code like the
+ following:</para>
+
+ <programlisting>uint64_t t;
+int msec;
+sd_journal_get_timeout(m, &t);
+if (t == (uint64_t) -1)
+ msec = -1;
+else {
+ struct timespec ts;
+ uint64_t n;
+ clock_getttime(CLOCK_MONOTONIC, &ts);
+ n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+ msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
+}</programlisting>