Commit graph

148 commits

Author SHA1 Message Date
Lewis Baker
86a429aead WIP: generic variadic when_all() implementation. 2017-09-02 10:21:38 +09:30
Lewis Baker
d07d48eff0 Experimental implementation of generalised sync_wait().
Causes some test failures which I still need to look into.
2017-09-02 10:08:56 +09:30
Lewis Baker
e7870443d7 Add awaitable_traits, is_awaitable, is_awaiter template metafuntions 2017-09-02 09:58:15 +09:30
Lewis Baker
de0b0f4395 Add #include <ostream> to shared_task_tests.cpp
This fixes a missing-symbol linker error under Clang optimised
builds under Linux.
2017-08-24 23:00:40 +09:30
Lewis Baker
25a5207035 Put cancellation_token tests into a test suite. 2017-08-24 22:59:06 +09:30
Lewis Baker
62cff52fd1 Put local functions from tests into anonymous namespaces.
This fixes some duplicate-symbol linker errors under Linux/Clang.
Both generator_test.cpp and recursive_generator_tests.cpp were
defining a 'range' function.
2017-08-24 22:58:51 +09:30
Lewis Baker
3d97b79294 Silence some Clang warnings about unused return values in tests. 2017-08-24 22:47:30 +09:30
Lewis Baker
8a632c72a9 Don't link against 'c++abi' library under Linux/Clang.
The README instructions say to use the libstdc++ ABI so we don't
need to use the libc++abi.
2017-08-24 22:46:04 +09:30
Lewis Baker
ce4b4f5681 Add missing scheduling_operator_tests.cpp from previous commit. 2017-08-24 22:41:19 +09:30
Lewis Baker
81de379342 Add schedule_on() and resume_on() functions. 2017-08-22 07:14:25 +09:30
Lewis Baker
8e728932be Improvements to fmap() implementation
- Added documentation to README
- Implemented fmap() for generator<T>, recursive_generator<T>,
  shared_task<T>.
- Centralised operator| overloads for fmap() in fmap.hpp.
- Now provide two-argument fmap() overloads as the type-specific
  implementations: fmap(func, value)
  This replaces the need for detail::apply_fmap() functions.
2017-08-19 23:12:34 +09:30
Lewis Baker
2160ab0208 Update reference to VS 2017.3 in docs now that it's released. 2017-08-17 22:24:30 +09:30
Lewis Baker
316ce6c7dd Modify task<T> to avoid potential for unbounded recursion.
The await_suspend() method of operator co_await() now returns bool
instead of void, to allow it to resume execution without suspending
if the task completes synchronously. However, this unfortunately
requires use of std::atomic operations to decide a potential race
between the awaiter suspending and the coroutine running to
completion.

This avoids a stack-overflow error when a coroutine awaits a
long sequence of task<T> values that complete synchronously.
eg. in a loop.
2017-08-17 22:23:59 +09:30
Lewis Baker
bf9eb2c581 Rename lazy_task -> task, shared_lazy_task -> shared_task.
No need to keep the 'lazy' term in the name to distinguish it
from eager tasks as all task are lazy now.
2017-08-17 21:14:34 +09:30
lewissbaker
e04d430608 Merge pull request #33 from ub1985/master
Added documentation for sync_wait().
2017-08-17 14:07:54 +09:30
lewissbaker
f9b644e7c5 Minor formatting improvements to sync_wait() doco. 2017-08-17 14:06:30 +09:30
ub1985
1d4bf33269 added doc for sync_wait 2017-08-17 05:17:38 +02:00
Lewis Baker
e6355dfff4 Add documentation for when_all() and when_all_ready(). 2017-08-17 07:56:39 +09:30
Lewis Baker
1f78628967 Add when_all.hpp and when_all_ready.hpp to generated .vcproj 2017-08-17 07:56:21 +09:30
Lewis Baker
64b0a049f9 Remove eager task types task<T> and shared_task<T>.
These types make it difficult to write exception-safe code
when compared with their lazy-task counterparts.
2017-08-17 07:55:58 +09:30
Lewis Baker
cf997e9d82 Use -O3 when building under Clang. 2017-08-15 21:54:27 +09:30
Lewis Baker
db4c2c700d Fix compilation of sync_wait_tests.cpp on Linux.
#ifdef out tests that make use of io_service until we
have an implementation of io_service for Linux.
2017-08-15 21:49:34 +09:30
Lewis Baker
f099f37136 Fix compilation of lightweight_manual_reset_event on Linux 2017-08-15 21:48:39 +09:30
Lewis Baker
478ddb9715 Factor io_service test setup into io_service_fixture class. 2017-08-15 21:15:32 +09:30
Lewis Baker
421de76f18 Change when_all() tests to avoid use of task<T>.
Use lazy_task, sync_wait and when_all instead.
2017-08-15 20:37:34 +09:30
Lewis Baker
629b8fda7e Indentation fixes. 2017-08-14 21:39:59 +09:30
Lewis Baker
722fe1b24a Update when_all_ready_tests.cpp to avoid use of task<T>.
Use lazy_task<T> and sync_wait() instead.
2017-08-14 21:36:13 +09:30
Lewis Baker
b78bc3ed7b Update some tests to avoid using cppcoro::task<>.
Use lazy_task<>, sync_wait() and when_all[_ready]() instead in
preparation for phasing out task<>.
2017-08-14 09:20:52 +09:30
Lewis Baker
4acf3d5a4e Only use /await:heapelide on x64 optimised.
This flag is not supported for x86 targets yet.
2017-08-14 09:15:57 +09:30
Lewis Baker
3a581e633e Add cppcoro::sync_wait().
Allows synchronously waiting for a task to complete.
2017-08-14 09:14:20 +09:30
Lewis Baker
d6f005342d Make lightweight_manual_reset_event methods noexcept.
This is important to guarantee thread safety in some scenarios.
2017-08-10 22:37:11 +09:30
Lewis Baker
278c3181a6 Add detail::lightweight_manual_reset_event class.
Uses futex() on Linux, WaitOnAddress() on Win8+ and falls back to
Win32 events on earlier versions of Windows.
2017-08-10 07:34:09 +09:30
Lewis Baker
abc4dd60e1 Compile with /nodefaultlib under MSVC so we're forced to list libs.
This helps to ensure cake knows about those libraries which would
otherwise not be listed on the link line.
2017-08-10 07:08:03 +09:30
Lewis Baker
68ac82e739 Turn on /await:heapelide for msvc optimised build variant. 2017-08-08 21:10:37 +09:30
lewissbaker
84fdbc7971 Add '-fuse-ld=lld` to link line to force use of LLD
This avoids needing to setup the 'ld' symbolic link which points to 'lld'.
2017-08-07 10:23:45 +09:30
lewissbaker
8970e17b46 Merge pull request #26 from lewissbaker/clang
Add support for building under Clang and Linux
2017-08-06 19:27:11 +09:30
Lewis Baker
e0260d4278 Add documentation to README about building under Linux. 2017-08-06 16:29:36 +09:30
Lewis Baker
75e9a18c06 Move libc++ path customisation point nearer to clang's. 2017-08-06 14:55:11 +09:30
Lewis Baker
83ab6399ec Suppress some Clang warnings about unused return values.
Cast result to (void) where we are intentionally ignoring
the return value.
2017-08-03 00:12:47 +09:30
Lewis Baker
4c7569cb50 Merge branch 'master' of github.com:lewissbaker/cppcoro into clang
# Conflicts:
#	test/build.cake
2017-08-02 21:31:56 +09:30
Lewis Baker
7513d9cf0c Remove hack workaround for co_return <void-expr> under clang.
This bug has been fixed in clang-6.0.
2017-08-02 21:30:17 +09:30
Lewis Baker
dbfa380acc Fix whitespace. 2017-08-02 21:29:17 +09:30
Lewis Baker
4f4dbd5f0a Update config.cake to not be specific to clang-5.0
It now supports being built with clang 6.0.
2017-08-02 21:28:56 +09:30
Lewis Baker
67fea7fe53 Add when_all() and when_all_ready().
Add 'get_starter()' methods to all task types.
Add detail::unwrap_reference_t helper.
Add detail::when_all_awaitable helper.
2017-08-02 08:32:10 +09:30
Lewis Baker
671ac0b006 Rename 'resumer' class to 'continuation'.
The name 'continuation' much better matches the concept.
2017-08-02 08:32:10 +09:30
Lewis Baker
424af55f41 Fix path to 'Detail' headers in generated cppcoro.vcproj 2017-08-02 08:32:08 +09:30
Lewis Baker
954588ccfa Enable make_shared_task(lazy_task<void>) workaround under clang. 2017-08-02 08:32:08 +09:30
Lewis Baker
5f5bfa9649 Add 'value_type' typedefs to each of the task-types.
This typedef just makes available the template parameter of the
task type. This can be useful when writing generic functions that
need to operate on any of the task-types.
2017-08-02 08:32:07 +09:30
Lewis Baker
c22bef61a9 Modify task classes to support storing callback and pointer.
This allows registering continuations that are not coroutine
handles which can be useful for building some operators.
This comes at the expense of storage of an extra pointer per
coroutine and/or awaiter.

Adds the cppcoro::detail::resumer to wrap something that can
either be a callback + state or a coroutine_handle.
2017-08-02 08:32:07 +09:30
lewissbaker
9dc7b36296 Fix bug in io_service::try_enter_event_loop()
A missing '!' on the compare_exchange_weak() while-loop condition.
2017-08-01 12:08:23 +09:30