Skip to content

Commit

Permalink
Merge branch 'dm/windows' into 'master'
Browse files Browse the repository at this point in the history
dm/windows

See merge request Tanker/tconcurrent!3
  • Loading branch information
dmerejkowsky committed Mar 1, 2019
2 parents 2e63b67 + fd3d7a1 commit 1e1905c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
image: tanker.local:5000/ci-cpp:latest

before_script:
- dmenv install

Expand Down
31 changes: 25 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)


set(tconcurrent_SRC
include/tconcurrent/async.hpp
include/tconcurrent/async_wait.hpp
include/tconcurrent/barrier.hpp
include/tconcurrent/cancelation_token.hpp
include/tconcurrent/concurrent_queue.hpp
include/tconcurrent/coroutine.hpp
include/tconcurrent/detail/boost_fwd.hpp
include/tconcurrent/detail/export.hpp
include/tconcurrent/detail/shared_base.hpp
include/tconcurrent/detail/util.hpp
include/tconcurrent/executor.hpp
include/tconcurrent/future.hpp
include/tconcurrent/future_group.hpp
include/tconcurrent/job.hpp
include/tconcurrent/packaged_task.hpp
include/tconcurrent/periodic_task.hpp
include/tconcurrent/promise.hpp
include/tconcurrent/semaphore.hpp
include/tconcurrent/stackful_coroutine.hpp
include/tconcurrent/stackless_coroutine.hpp
include/tconcurrent/stepper.hpp
include/tconcurrent/task_auto_canceler.hpp
include/tconcurrent/thread_pool.hpp
include/tconcurrent/when.hpp
src/barrier.cpp
src/periodic_task.cpp
src/stepper.cpp
Expand All @@ -30,19 +54,14 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
src/executor_emscripten.cpp
)
else()
find_package(Boost 1.61 REQUIRED COMPONENTS system thread context)

list(APPEND tconcurrent_SRC
src/async_wait.cpp
src/executor.cpp
src/stackful_coroutine.cpp
src/thread_pool.cpp
)
list(APPEND tconcurrent_LIBS
# Keep components, to avoid linking with everything
Boost::system
Boost::thread
Boost::context
CONAN_PKG::Boost
CONAN_PKG::enum-flags
)
endif()
Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
doctest/2.0.1@tanker/testing

[requires]
Boost/1.66.0@tanker/testing
Boost/1.68.0@tanker/testing
enum-flags/0.1a@tanker/testing

[generators]
Expand Down
13 changes: 11 additions & 2 deletions include/tconcurrent/stackful_coroutine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#include <sanitizer/common_interface_defs.h>
#endif

#if __cplusplus >= 201703L
#define TCONCURRENT_NODISCARD [[nodiscard]]
#elif defined(__GNUG__)
#define TCONCURRENT_NODISCARD __attribute__((warn_unused_result))
#else
#define TCONCURRENT_NODISCARD
#endif


namespace tconcurrent
{
template <typename E, typename F>
Expand Down Expand Up @@ -297,7 +306,7 @@ struct cotask_value
};

template <typename T>
class [[nodiscard]] cotask_impl {
class TCONCURRENT_NODISCARD cotask_impl {
public:
using value_type = T;

Expand All @@ -321,7 +330,7 @@ class [[nodiscard]] cotask_impl {
};

template <>
class [[nodiscard]] cotask_impl<void> {
class TCONCURRENT_NODISCARD cotask_impl<void> {
public:
using value_type = void;

Expand Down
8 changes: 4 additions & 4 deletions test/test_future.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ TEST_CASE("future<void> should work")

TEST_CASE("exceptional future")
{
auto future = make_exceptional_future<int>("FAIL");
auto future = make_exceptional_future<int>(std::invalid_argument{"kaboom"});
CHECK(future.is_ready());
CHECK(!future.has_value());
CHECK(future.has_exception());
CHECK_THROWS_AS(future.get(), char*);
CHECK_THROWS_AS(future.get(), std::invalid_argument);
}

TEST_CASE("exceptional future<void>")
{
auto future = make_exceptional_future<void>("FAIL");
auto future = make_exceptional_future<void>(std::invalid_argument{"kaboom"});
CHECK(future.is_ready());
CHECK(!future.has_value());
CHECK(future.has_exception());
CHECK_THROWS_AS(future.get(), char*);
CHECK_THROWS_AS(future.get(), std::invalid_argument);
}

TEST_CASE("future.wait_for should timeout properly [waiting]")
Expand Down

0 comments on commit 1e1905c

Please sign in to comment.