diff --git a/include/crow/crow.hpp b/include/crow/crow.hpp index 006e4eb..de1c74b 100644 --- a/include/crow/crow.hpp +++ b/include/crow/crow.hpp @@ -227,6 +227,12 @@ class crow */ void clear_context(); + /*! + * @brief waits for all pending posts/jobs to complete + * + */ + void wait_pending_jobs() const; + /*! * @} */ diff --git a/src/crow.cpp b/src/crow.cpp index 9a10180..b6942be 100644 --- a/src/crow.cpp +++ b/src/crow.cpp @@ -342,6 +342,14 @@ void crow::clear_context() } } +void crow::wait_pending_jobs() const { + std::lock_guard lock_jobs(m_jobs_mutex); + + for (auto it = m_jobs.begin(); it != m_jobs.end(); ++it) { + it->wait(); + } +} + std::string crow::post(json payload) const { curl_wrapper curl;