Commit graph

7 commits

Author SHA1 Message Date
Lewis Baker 5ea774d1f9 Make more functions work with arbitrary awaitables.
- Change fmap, schedule_on, resume_on, make_shared_task work with
  arbitrary awaitables.
- Add make_task to wrap an arbitrary awaitable in a task<T>.
- Remove specialisation of fmap() for task<T>, shared_task<T> as
  the generalised version obsoletes it.
2017-09-13 08:26:43 +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 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
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 1871e52a7f Add fmap() and implement transform for task<T> and lazy_task<T>. 2017-07-11 08:35:46 +09:30
Lewis Baker 9a620aa4c5 Change tests to use doctest testing framework.
Break out tests to separate files per abstraction.
2017-05-22 06:34:19 +09:30