| 35 | /// @tparam RET The type of value returned via the promise associated with this context. |
| 36 | template <class RET> |
| 37 | struct IThreadContext : public IThreadContextBase |
| 38 | { |
| 39 | using ContextTag = ThreadContextTag; |
| 40 | using Ptr = std::shared_ptr<IThreadContext<RET>>; |
| 41 | using Impl = Context<RET>; |
| 42 | |
| 43 | /// @brief Waits for the future associated with this context to be ready. |
| 44 | /// @note Blocks until the future is ready or until an exception is thrown. |
| 45 | virtual void wait() const = 0; |
| 46 | |
| 47 | /// @brief Waits for the future associated with this context to be ready for a maximum of 'timeMs' milliseconds. |
| 48 | /// @param[in] timeMs The maximum amount of milliseconds to wait until the future value becomes ready. |
| 49 | /// @return 'ready' if value was posted before duration expired or 'timeout' otherwise. |
| 50 | /// @note Blocks until the value is ready, until 'timeMs' duration expires or until an exception is thrown. |
| 51 | virtual std::future_status waitFor(std::chrono::milliseconds timeMs) const = 0; |
| 52 | |
| 53 | /// @brief Waits for the future in the 'num-th' continuation context to be ready. |
| 54 | /// @details Allowed range for num is [-1, total_continuations). -1 is equivalent of calling wait() or |
| 55 | /// waitAt(total_continuations-1) on the last context in the chain (i.e. the context which is returned |
| 56 | /// via end()). Position 0 represents the first future in the chain. |
| 57 | /// @param[in] num The number indicating which future to wait on. |
| 58 | /// @note Blocks until the value is ready or an exception is thrown. |
| 59 | virtual void waitAt(int num) const = 0; |
| 60 | |
| 61 | /// @brief Waits for the future in the 'num-th' continuation context to be ready for a maximum of 'timeMs' milliseconds. |
| 62 | /// @details Allowed range for num is [-1, total_continuations). -1 is equivalent of calling wait() or |
| 63 | /// waitAt(total_continuations-1) on the last context in the chain (i.e. the context which is returned |
| 64 | /// via end()). Position 0 represents the first future in the chain. |
| 65 | /// @param[in] num The number indicating which future to wait on. |
| 66 | /// @param[in] timeMs The maximum amount of milliseconds to wait until the future value becomes ready. |
| 67 | /// @return 'ready' if value was posted before duration expired or 'timeout' otherwise. |
| 68 | /// @note Blocks until the value is ready, until 'timeMs' duration expires or until an exception is thrown. |
| 69 | virtual std::future_status waitForAt(int num, std::chrono::milliseconds timeMs) const = 0; |
| 70 | |
| 71 | /// @brief Wait for all the futures in the continuation chain to be ready. |
| 72 | /// @note Blocks until all future values are ready. If any future throws, the exception is swallowed. |
| 73 | virtual void waitAll() const = 0; |
| 74 | |
| 75 | /// @brief Get the future value associated with this context. |
| 76 | /// @note Blocks until the future is ready or until an exception is thrown. Once this function returns, the future |
| 77 | /// becomes invalidated (i.e. cannot be read again). |
| 78 | template <class V = RET> |
| 79 | NonBufferRetType<V> get(); |
| 80 | |
| 81 | /// @brief Get a reference the future value associated with this context. |
| 82 | /// @return A reference to the future value. |
| 83 | /// @note Blocks until the future is ready or until an exception is thrown. Contrary to get(), this function does |
| 84 | /// not invalidate the future and as such may be read again. |
| 85 | template <class V = RET> |
| 86 | const NonBufferRetType<V>& getRef() const; |
| 87 | |
| 88 | /// @brief Get the future value from the 'num-th' continuation context. |
| 89 | /// @details Allowed range for num is [-1, total_continuations). -1 is equivalent of calling get() or |
| 90 | /// getAt(total_continuations-1) on the last context in the chain (i.e. the context which is returned |
| 91 | /// via end()). Position 0 represents the first future in the chain. |
| 92 | /// @tparam OTHER_RET The type of the future value associated with the 'num-th' context. |
| 93 | /// @param[in] num The number indicating which future to wait on. |
| 94 | /// @return The future value of the 'num-th' thread context. |
nothing calls this directly
no outgoing calls
no test coverage detected