Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions .github/workflows/test_matrix.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
[
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 11,
"stdlib": "libc++",
"tsan": false,
"shared": false,
"name" : "ubuntu-20.04, clang-11, libc++, shared=false, tsan=false"
"name" : "ubuntu-24.04, clang-11, libc++, shared=false, tsan=false"
},
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 11,
"stdlib": "libc++",
"tsan": false,
"shared": true,
"name" : "ubuntu-20.04, clang-11, libc++, shared=true, tsan=false"
"name" : "ubuntu-24.04, clang-11, libc++, shared=true, tsan=false"
},
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 12,
"stdlib": "libc++",
"tsan": false,
"shared": false,
"name" : "ubuntu-20.04, clang-12, libc++, shared=false, tsan=false"
"name" : "ubuntu-24.04, clang-12, libc++, shared=false, tsan=false"
},
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 12,
"stdlib": "libc++",
"tsan": false,
"shared": true,
"name" : "ubuntu-20.04, clang-12, libc++, shared=true, tsan=false"
"name" : "ubuntu-24.04, clang-12, libc++, shared=true, tsan=false"
},
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 13,
"stdlib": "libc++",
"tsan": false,
"shared": false,
"name" : "ubuntu-20.04, clang-13, libc++, shared=false, tsan=false"
"name" : "ubuntu-24.04, clang-13, libc++, shared=false, tsan=false"
},
{
"os": "ubuntu-20.04",
"os": "ubuntu-24.04",
"clang-version": 13,
"stdlib": "libc++",
"tsan": false,
"shared": true,
"name" : "ubuntu-20.04, clang-13, libc++, shared=true, tsan=false"
"name" : "ubuntu-24.04, clang-13, libc++, shared=true, tsan=false"
},
{
"os": "ubuntu-22.04",
Expand Down Expand Up @@ -250,40 +250,40 @@
"name" : "windows-2022, clang-16, msvc-stl, shared=true, tsan=false"
},
{
"os": "macos-12",
"os": "macos-15",
"stdlib": "libc++",
"tsan": false,
"shared": false,
"name" : "macos-12, clang, libc++, shared=false, tsan=false"
"name" : "macos-15, clang, libc++, shared=false, tsan=false"
},
{
"os": "macos-12",
"os": "macos-15",
"stdlib": "libc++",
"tsan": false,
"shared": true,
"name" : "macos-12, clang, libc++, shared=true, tsan=false"
"name" : "macos-15, clang, libc++, shared=true, tsan=false"
},
{
"os": "macos-12",
"os": "macos-15",
"stdlib": "libc++",
"tsan": true,
"shared": false,
"name" : "macos-12, clang, libc++, shared=false, tsan=true"
"name" : "macos-15, clang, libc++, shared=false, tsan=true"
},
{
"os": "macos-12",
"os": "macos-15",
"gcc-version": 13,
"stdlib": "libstdc++",
"tsan": false,
"shared": false,
"name" : "macos-12, gcc-13, libstdc++-13, shared=false, tsan=false"
"name" : "macos-15, gcc-13, libstdc++-13, shared=false, tsan=false"
},
{
"os": "macos-12",
"os": "macos-15",
"gcc-version": 13,
"stdlib": "libstdc++",
"tsan": false,
"shared": true,
"name" : "macos-12, gcc-13, libstdc++-13, shared=true, tsan=false"
"name" : "macos-15, gcc-13, libstdc++-13, shared=true, tsan=false"
}
]
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ set(concurrencpp_sources
source/threads/thread.cpp
source/timers/timer.cpp
source/timers/timer_queue.cpp
source/utils/throw_helper.cpp
source/utils/math_helper.cpp)

set(concurrencpp_headers
Expand Down Expand Up @@ -78,10 +79,10 @@ set(concurrencpp_headers
include/concurrencpp/threads/async_condition_variable.h
include/concurrencpp/threads/thread.h
include/concurrencpp/threads/cache_line.h
include/concurrencpp/timers/constants.h
include/concurrencpp/timers/timer.h
include/concurrencpp/timers/timer_queue.h
include/concurrencpp/utils/bind.h
include/concurrencpp/utils/throw_helper.h
include/concurrencpp/utils/math_helper.h
include/concurrencpp/utils/slist.h
include/concurrencpp/utils/dlist.h)
Expand Down
2 changes: 2 additions & 0 deletions include/concurrencpp/errors.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef CONCURRENCPP_ERRORS_H
#define CONCURRENCPP_ERRORS_H

#include "concurrencpp/platform_defs.h"

#include <stdexcept>

namespace concurrencpp::errors {
Expand Down
14 changes: 7 additions & 7 deletions include/concurrencpp/executors/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
#include <numeric>

namespace concurrencpp::details::consts {
inline const char* k_inline_executor_name = "concurrencpp::inline_executor";
inline const char* k_inline_executor_name = "inline_executor";
constexpr int k_inline_executor_max_concurrency_level = 0;

inline const char* k_thread_executor_name = "concurrencpp::thread_executor";
inline const char* k_thread_executor_name = "thread_executor";
constexpr int k_thread_executor_max_concurrency_level = std::numeric_limits<int>::max();

inline const char* k_thread_pool_executor_name = "concurrencpp::thread_pool_executor";
inline const char* k_background_executor_name = "concurrencpp::background_executor";
inline const char* k_thread_pool_executor_name = "thread_pool_executor";
inline const char* k_background_executor_name = "background_executor";

constexpr int k_worker_thread_max_concurrency_level = 1;
inline const char* k_worker_thread_executor_name = "concurrencpp::worker_thread_executor";
inline const char* k_worker_thread_executor_name = "worker_thread_executor";

inline const char* k_manual_executor_name = "concurrencpp::manual_executor";
inline const char* k_manual_executor_name = "manual_executor";
constexpr int k_manual_executor_max_concurrency_level = std::numeric_limits<int>::max();

inline const char* k_timer_queue_name = "concurrencpp::timer_queue";
inline const char* k_timer_queue_name = "timer_queue";

inline const char* k_executor_shutdown_err_msg = " - shutdown has been called on this executor.";
} // namespace concurrencpp::details::consts
Expand Down
5 changes: 2 additions & 3 deletions include/concurrencpp/executors/executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <string_view>

namespace concurrencpp::details {
[[noreturn]] CRCPP_API void throw_runtime_shutdown_exception(std::string_view executor_name);
CRCPP_API std::string make_executor_worker_name(std::string_view executor_name);
} // namespace concurrencpp::details

Expand Down Expand Up @@ -111,12 +110,12 @@ namespace concurrencpp {
}

public:
const std::string name;

executor(std::string_view name) : name(name) {}

virtual ~executor() noexcept = default;

const std::string name;

virtual void enqueue(concurrencpp::task task) = 0;
virtual void enqueue(std::span<concurrencpp::task> tasks) = 0;

Expand Down
2 changes: 1 addition & 1 deletion include/concurrencpp/executors/inline_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace concurrencpp {

void throw_if_aborted() const {
if (m_abort.load(std::memory_order_relaxed)) {
details::throw_runtime_shutdown_exception(name);
details::throw_helper::throw_worker_shutdown_exception(name, "enqueue");
}
}

Expand Down
20 changes: 12 additions & 8 deletions include/concurrencpp/executors/manual_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ namespace concurrencpp {
return std::chrono::system_clock::now() + ms;
}

size_t loop_impl(size_t max_count);
size_t loop_until_impl(size_t max_count, std::chrono::time_point<std::chrono::system_clock> deadline);
size_t loop_impl(size_t max_count, const char* calling_method);
size_t loop_until_impl(size_t max_count,
std::chrono::time_point<std::chrono::system_clock> deadline,
const char* calling_method);

void wait_for_tasks_impl(size_t count);
size_t wait_for_tasks_impl(size_t count, std::chrono::time_point<std::chrono::system_clock> deadline);
void wait_for_tasks_impl(size_t count, const char* calling_method);
size_t wait_for_tasks_impl(size_t count,
std::chrono::time_point<std::chrono::system_clock> deadline,
const char* calling_method);

public:
manual_executor();
Expand All @@ -58,31 +62,31 @@ namespace concurrencpp {

template<class clock_type, class duration_type>
bool loop_once_until(std::chrono::time_point<clock_type, duration_type> timeout_time) {
return loop_until_impl(1, to_system_time_point(timeout_time));
return loop_until_impl(1, to_system_time_point(timeout_time), "loop_once_until");
}

size_t loop(size_t max_count);
size_t loop_for(size_t max_count, std::chrono::milliseconds max_waiting_time);

template<class clock_type, class duration_type>
size_t loop_until(size_t max_count, std::chrono::time_point<clock_type, duration_type> timeout_time) {
return loop_until_impl(max_count, to_system_time_point(timeout_time));
return loop_until_impl(max_count, to_system_time_point(timeout_time), "loop_until");
}

void wait_for_task();
bool wait_for_task_for(std::chrono::milliseconds max_waiting_time);

template<class clock_type, class duration_type>
bool wait_for_task_until(std::chrono::time_point<clock_type, duration_type> timeout_time) {
return wait_for_tasks_impl(1, to_system_time_point(timeout_time)) == 1;
return wait_for_tasks_impl(1, to_system_time_point(timeout_time), "wait_for_task_until") == 1;
}

void wait_for_tasks(size_t count);
size_t wait_for_tasks_for(size_t count, std::chrono::milliseconds max_waiting_time);

template<class clock_type, class duration_type>
size_t wait_for_tasks_until(size_t count, std::chrono::time_point<clock_type, duration_type> timeout_time) {
return wait_for_tasks_impl(count, to_system_time_point(timeout_time));
return wait_for_tasks_impl(count, to_system_time_point(timeout_time), "wait_for_tasks_until");
}
};
} // namespace concurrencpp
Expand Down
94 changes: 1 addition & 93 deletions include/concurrencpp/results/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,113 +6,21 @@ namespace concurrencpp::details::consts {
* result_promise
*/

inline const char* k_result_promise_set_result_error_msg = "concurrencpp::result_promise::set_result() - empty result_promise.";

inline const char* k_result_promise_set_exception_error_msg =
"concurrencpp::result_promise::set_exception() - empty result_promise.";

inline const char* k_result_promise_set_exception_null_exception_error_msg =
"concurrencpp::result_promise::set_exception() - exception pointer is null.";

inline const char* k_result_promise_set_from_function_error_msg =
"concurrencpp::result_promise::set_from_function() - empty result_promise.";

inline const char* k_result_promise_get_result_error_msg = "concurrencpp::result_promise::get_result() - empty result_promise.";

inline const char* k_result_promise_get_result_already_retrieved_error_msg =
"concurrencpp::result_promise::get_result() - result was already retrieved.";

/*
* result
*/

inline const char* k_result_status_error_msg = "concurrencpp::result::status() - result is empty.";

inline const char* k_result_get_error_msg = "concurrencpp::result::get() - result is empty.";

inline const char* k_result_wait_error_msg = "concurrencpp::result::wait() - result is empty.";

inline const char* k_result_wait_for_error_msg = "concurrencpp::result::wait_for() - result is empty.";

inline const char* k_result_wait_until_error_msg = "concurrencpp::result::wait_until() - result is empty.";

inline const char* k_result_operator_co_await_error_msg = "concurrencpp::result::operator co_await() - result is empty.";

inline const char* k_result_resolve_error_msg = "concurrencpp::result::resolve() - result is empty.";

inline const char* k_executor_exception_error_msg =
"concurrencpp::concurrencpp::result - an exception was thrown while trying to enqueue result continuation.";


inline const char* k_broken_task_exception_error_msg = "concurrencpp::result - associated task was interrupted abnormally";

/*
* when_xxx
*/

inline const char* k_make_exceptional_result_exception_null_error_msg =
"concurrencpp::make_exceptional_result() - given exception_ptr is null.";

inline const char* k_make_exceptional_lazy_result_exception_null_error_msg =
"concurrencpp::make_exceptional_lazy_result() - given exception_ptr is null.";

inline const char* k_when_all_empty_result_error_msg = "concurrencpp::when_all() - one of the result objects is empty.";

inline const char* k_when_all_null_resume_executor_error_msg = "concurrencpp::when_all() - given resume_executor is null.";

inline const char* k_when_any_empty_result_error_msg = "concurrencpp::when_any() - one of the result objects is empty.";

inline const char* k_when_any_empty_range_error_msg = "concurrencpp::when_any() - given range contains no elements.";

inline const char* k_when_any_null_resume_executor_error_msg = "concurrencpp::when_any() - given resume_executor is null.";

/*
* shared_result
*/

inline const char* k_shared_result_status_error_msg = "concurrencpp::shared_result::status() - result is empty.";

inline const char* k_shared_result_get_error_msg = "concurrencpp::shared_result::get() - result is empty.";

inline const char* k_shared_result_wait_error_msg = "concurrencpp::shared_result::wait() - result is empty.";

inline const char* k_shared_result_wait_for_error_msg = "concurrencpp::shared_result::wait_for() - result is empty.";

inline const char* k_shared_result_wait_until_error_msg = "concurrencpp::shared_result::wait_until() - result is empty.";

inline const char* k_shared_result_operator_co_await_error_msg =
"concurrencpp::shared_result::operator co_await() - result is empty.";

inline const char* k_shared_result_resolve_error_msg = "concurrencpp::shared_result::resolve() - result is empty.";

/*
* lazy_result
*/

inline const char* k_empty_lazy_result_status_err_msg = "concurrencpp::lazy_result::status - result is empty.";

inline const char* k_empty_lazy_result_operator_co_await_err_msg =
"concurrencpp::lazy_result::operator co_await - result is empty.";

inline const char* k_empty_lazy_result_resolve_err_msg = "concurrencpp::lazy_result::resolve - result is empty.";

inline const char* k_empty_lazy_result_run_err_msg = "concurrencpp::lazy_result::run - result is empty.";

/*
* resume_on
*/

inline const char* k_resume_on_null_exception_err_msg = "concurrencpp::resume_on - given executor is null.";

/*
* generator
*/
inline const char* k_empty_generator_begin_err_msg = "concurrencpp::generator::begin - generator is empty.";

/*
* parallel-coroutine
*/
inline const char* k_parallel_coroutine_null_exception_err_msg = "concurrencpp::parallel-coroutine - given executor is null.";

} // namespace concurrencpp::details::consts

#endif
Loading
Loading