Commit graph

136 commits

Author SHA1 Message Date
Andreas Buhr fdb7a74f63 translate "for co_await" to regular for loops using "co_await"
"for co_await" was in the coroutine-ts but did not make it into
the C++20 standard. This patch translates the "for co_await"
which were used to standard for loops using "co_await".
This is necessary to compile on MSVC 1928 in with c++-latest.
2020-10-12 10:38:08 -07:00
Andreas Buhr a5ed331c94 Fixes for MSVC 1928
First, std::uncought_exception() does not exist any more in
C++20, it is replaced by std::uncought_exceptions(). Second,
Second, in file_test.cpp we have to include <string>
to use std::to_string.
2020-10-12 10:36:45 -07:00
Lewis Baker c1ea9b412f Disable socket test that causes an ICE under msvc x86. 2019-09-03 21:28:55 -07:00
Lewis Baker 17bd85ac36
Merge pull request #92 from lewissbaker/disruptor
Add synchronisation primitives for ring-buffered producer/consumer
2019-01-21 22:27:13 -08:00
Lewis Baker 8e9db4c48a Perfectly-forward generator<T>::iterator::reference type to fmap(). 2019-01-18 22:14:12 -08:00
Lewis Baker 73f75a3efe
Merge branch 'master' into disruptor 2019-01-15 10:53:09 -08:00
Lewis Baker c6a25679f7 Fix inability to 'co_yield' a non-const T& from generator<const T>.
Fixes #88.
2019-01-01 21:16:06 -08:00
Lewis Baker 3cdc22bbed Make the ring-buffer wait operations take a scheduler.
The awaiting coroutine will be resumed using the scheduler if it
is suspended waiting for a sequence number. This simplifies code
as the caller doesn't need to remember to manually reschedule.
Forcing a scheduler to provided also prevents the producer/consumer
coroutines from effectively becoming single-threaded.
2018-10-30 23:31:36 -07:00
Lewis Baker 669fabed26 Switch more tests to use static_thread_pool. 2018-10-27 12:22:36 -07:00
Lewis Baker ed172f6941 Port some tests to use static_thread_pool instead of io_service.
This should allow them to be run under Linux/Clang.
2018-10-27 12:16:50 -07:00
Lewis Baker 8745d1b6d6 Change ring-buffer sequencer tests to use static_thread_pool.
This will allow them to be run on Linux platforms.

Change producer in multi-producer examples to reschedule onto the
thread-pool if probably suspended. This allows producer and
consumer to run concurrently rather than the consumer executing
the producer inline.
2018-10-27 12:06:14 -07:00
Lewis Baker e25d12f06e
Merge branch 'master' into disruptor 2018-10-21 09:02:44 -07:00
Lewis Baker 6536f91567
Merge branch 'master' into symmetric_transfer 2018-10-17 21:42:08 -07:00
Lewis Baker 02421f1006 Modify async_generator_tests to permit lazy .begin(), iterator++.
This should fix the test under Clang which use symmetric-transfer.
2018-10-04 20:11:17 -07:00
Lewis Baker 3d90fff93f Re-enable disabled test under msvc 2017.9 Preview 3 or later.
The bug seems to have been fixed now.
2018-10-03 22:00:30 -07:00
Lewis Baker 4438364b2b Don't compile many-connection test under MSVC x86.
It causes an internal-compile-error under VS 2017.8 and
2017.9 Preview 1/2.
2018-09-13 20:33:22 -07:00
Lewis Baker 99f679d3b6 Fix many-connection socket test.
It wasn't using a large-enough connection backlog when listening.
2018-09-10 22:15:21 -07:00
Lewis Baker 6e97c226a6 Change async_scope to use .join() method.
Instead of awaiting the scope directly.
This makes the intent more explicit at the co_await call site.
2018-09-09 23:17:11 -07:00
Lewis Baker 0b84e9c9b7 Add socket test for handling many concurrent connections.
Uses async_scope to start handling each connection eagerly
and waiting until all connections have finished.
2018-09-09 23:12:24 -07:00
Lewis Baker e23897adc4
Merge branch 'master' into sockets2 2018-08-20 21:07:17 -07:00
Lewis Baker 8357f3a9eb
Merge branch 'master' into static_thread_pool 2018-08-20 12:58:58 -07:00
Lewis Baker 868c0f427d Merge branch 'master' into generic_ops 2018-08-15 22:18:25 -07:00
Lewis Baker ac76fcf5de
Merge branch 'master' into static_thread_pool 2018-08-09 08:46:40 -07:00
Lewis Baker 2115feeb50 Fix occasionally-failing test in scheduling_operator_tests.cpp
Disabled a CHECK() for the thread that the schedule_on() operator
resumes on since the outcome is actually not guaranteed with the
current implementation of task<T>. See #79 for details.
2018-08-08 08:16:46 -07:00
Lewis Baker 4900f94b38 Make for_each_async() execute the first iteration onto scheduler. 2018-08-06 23:51:21 -07:00
Lewis Baker d5bb99b4e4 Fix type truncation warning under 32-bit platforms. 2018-08-06 23:27:46 -07:00
Lewis Baker b17d9465b5
Add missing #include 2018-08-06 09:27:18 -07:00
Lewis Baker 0bf30e7d1a Declare await_suspend() noinline to workaround msvc bug.
MSVC was inlining local variables in await_suspend() into the
coroutine frame of the caller which was breaking the guarantees
required by the for_each_async() test.
2018-08-06 08:45:17 -07:00
Lewis Baker 73d24f4689 Add test showing parallel for_each using continuation stealing.
This allows parallel execution of a bulk operation using only
a single coroutine frame. The continuation of the loop is eligible
to be stolen by other threads while executing the current iteration.
2018-08-06 08:40:11 -07:00
Lewis Baker 398fb1dc1f Fix static_thread_pool crashes.
- thread_state::m_mask was being incorrectly initialised
- Modified try_local_enqueue() to attempt to enlarge the local
  queue if it looks like it's run out of space.
- Removed doubly-linked list from schedule_operation as it wasn't
  needed.
- Catch any potential exceptions thrown by auto_reset_event::wait()
  and just sleep for 1ms in this case rather than terminating the
  thread.
2018-08-03 08:25:09 -07:00
Lewis Baker c6d5f6a738 WIP version of static_thread_pool.
Still seems to have some bugs that cause crashes in the tests.
2018-07-31 08:09:09 -07:00
Lewis Baker 9185e33e54
Merge branch 'master' into generic_ops 2018-04-06 15:26:25 +09:30
Lewis Baker bce2a72817
Replace <iosfwd> with <ostream> in doctest.h to try and fix linker errors under Linux (#78) 2018-04-06 15:25:51 +09:30
Lewis Baker 4a66d0889f
Merge branch 'master' into generic_ops 2018-04-06 11:38:49 +09:30
grishavanika 14ad4bd5dd Fix io_service_fixture_with_threads: create given threads count (#75) 2018-04-05 16:14:57 +09:30
Lewis Baker 054631b1fd Skip failing when_all() test on msvc x86 optimised.
It seems to be failing due to an msvc compiler bug.
2018-03-26 23:22:40 +10:30
Lewis Baker 3ca50b3f25 Add some printf to "write a file" test. 2018-01-14 09:15:52 +10:30
Lewis Baker bcd6a2d465 Change 'write a file' test to be single-threaded.
Attempting to eliminate a race-condition as a potential cause of
a crash in this test.
2018-01-13 21:00:51 +10:30
Lewis Baker 16e0df5b5c Add basic send_to/recv_from functionality to socket class. 2018-01-12 06:35:51 +10:30
Lewis Baker 664537595e Add some basic Win32 async socket abstractions.
- Adds cppcoro::net::socket class with support for TCP/UDP
  over IPv4 or IPv6.
- Adds async accept/connect/disconnect/send/recv operations in
  both cancellable and non-cancellable variants.
- Still need to add send_to/recv_from as well as overloads for
  multi-buffer send/recv.
2018-01-12 06:35:15 +10:30
Lewis Baker a0fa1f84b7
Merge branch 'master' into generic_ops 2018-01-08 12:22:20 +10:30
Lewis Baker 447a6e69b5 Force doctest to flush each message to stdout.
This should avoid missing messages due to buffering should the
process crash soon after a message was written.
2018-01-08 11:17:20 +10:30
Lewis Baker 02d1822103 Fix warning about shadowed variables. 2018-01-08 11:17:20 +10:30
Lewis Baker d2bb79c256 Disable some tests under MSVC x86 optimised build variants.
Compiler is generating bad code for these tests under Visual Studio
15 Update 5.
2018-01-08 11:17:20 +10:30
Lewis Baker 7a900c1e9c Disable "low_pass" generator test
It was failing under MSVC x86 builds.
2018-01-08 11:17:20 +10:30
Lewis Baker 980fbdfddb Make doctest output the name of the test before running it. 2018-01-08 11:17:20 +10:30
Lewis Baker 36be19a349 Refactor file_read/write_operation classes for Win32.
- Move common logic for Win32 OVERLAPPED-based operations out into
  new win32_overlapped_operation[_cancellable] base-classes.
  The concrete I/O operation classes are now greatly simplified
  due to the reduction of boilerplate.
- Added overloads for read() and write() functions that don't
  take a cancellation_token that return a simpler awaitable type
  that generates much simpler assembly.
2017-12-27 19:36:14 +10:30
Lewis Baker d6edb80900 Add generator<T> test-case/example for low_pass() filter. 2017-12-19 20:43:48 +10:30
Lewis Baker 338c43f227 Add ip_address and ip[v4/v6]_endpoint. 2017-12-18 22:48:00 +10:30
Lewis Baker 7e049f6b79 Add cppcoro::net::ipv6_address. 2017-12-16 21:31:41 +10:30