]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/seastar/include/seastar/util/later.hh
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / seastar / include / seastar / util / later.hh
index cacce1440d4058bba19d7489ab96a74e9f1846cd..d1cc3ab908b70ebe95ff674eac0e8503777d69c2 100644 (file)
@@ -37,6 +37,46 @@ future<> now() {
 }
 
 /// \brief Returns a future which is not ready but is scheduled to resolve soon.
+///
+/// Schedules a future to run "soon". yield() can be used to break long-but-finite
+/// loops into pieces. Note that if nothing else is runnable,
+/// It will not check for I/O, and so an infinite loop with yield() will just
+/// burn CPU. 
+future<> yield() noexcept;
+
+/// Yield the cpu if the task quota is exhausted.
+///
+/// Check if the current continuation is preempted and yield if so. Otherwise
+/// return a ready future.
+///
+/// \note Threads and coroutines (see seastar::thread::maybe_yield() and 
+///       seastar::coroutine::maybe_yield() have their own custom variants,
+///       and the various continuation-based loops (do_for_each() and similar)
+///       do this automatically.
+inline
+future<> maybe_yield() noexcept {
+    if (need_preempt()) {
+        return yield();
+    } else {
+        return make_ready_future<>();
+    }
+}
+
+/// Force the reactor to check for pending I/O
+///
+/// Schedules a check for new I/O completions (disk operations completions
+/// or network packet arrival) immediately and return a future that is ready
+/// when the I/O has been polled for.
+///
+/// \note It is very rare to need to call this function. It is better to let the
+///       reactor schedule I/O polls itself.
+/// \note This has no effect on I/O polling on other shards.
+future<> check_for_io_immediately() noexcept;
+
+/// \brief Returns a future which is not ready but is scheduled to resolve soon.
+///
+/// \deprecated Use yield() instead, or check_for_io_immediately() if your really need it.
+[[deprecated("Use yield() or check_for_io_immediately()")]]
 future<> later() noexcept;
 
 /// @}