@@ -4,50 +4,49 @@ The 'cppcoro' library provides a set of general-purpose primitives for making us
4
4
5
5
These include:
6
6
* Coroutine Types
7
- * ` task<T> `
8
- * ` shared_task<T> `
9
- * ` generator<T> `
10
- * ` recursive_generator<T> `
11
- * ` async_generator<T> `
7
+ * [ ` task<T> ` ] ( #taskt )
8
+ * [ ` shared_task<T> ` ] ( #shared_taskt )
9
+ * [ ` generator<T> ` ] ( #generatort )
10
+ * [ ` recursive_generator<T> ` ] ( #recursive_generatort )
11
+ * [ ` async_generator<T> ` ] ( #async_generatort )
12
12
* Awaitable Types
13
- * ` single_consumer_event `
14
- * ` single_consumer_async_auto_reset_event `
15
- * ` async_mutex `
16
- * ` async_manual_reset_event `
17
- * ` async_auto_reset_event `
18
- * ` async_latch `
19
- * ` sequence_barrier `
20
- * ` multi_producer_sequencer `
21
- * ` single_producer_sequencer `
13
+ * [ ` single_consumer_event ` ] ( #single_consumer_event )
14
+ * [ ` single_consumer_async_auto_reset_event ` ] ( #single_consumer_async_auto_reset_event )
15
+ * [ ` async_mutex ` ] ( #async_mutex )
16
+ * [ ` async_manual_reset_event ` ] ( #async_manual_reset_event )
17
+ * [ ` async_auto_reset_event ` ] ( #async_auto_reset_event )
18
+ * [ ` async_latch ` ] ( #async_latch )
19
+ * [ ` sequence_barrier ` ] ( #sequence_barrier )
20
+ * [ ` multi_producer_sequencer ` ] ( #multi_producer_sequencer )
21
+ * [ ` single_producer_sequencer ` ] ( #single_producer_sequencer )
22
22
* Functions
23
- * ` sync_wait() `
24
- * ` when_all() `
25
- * ` when_all_ready() `
26
- * ` fmap() `
27
- * ` schedule_on() `
28
- * ` resume_on() `
29
- * Cancellation
23
+ * [ ` sync_wait() ` ] ( #sync_wait )
24
+ * [ ` when_all() ` ] ( #when_all )
25
+ * [ ` when_all_ready() ` ] ( #when_all_ready )
26
+ * [ ` fmap() ` ] ( #fmap )
27
+ * [ ` schedule_on() ` ] ( #schedule_on )
28
+ * [ ` resume_on() ` ] ( #resume_on )
29
+ * [ Cancellation] ( #Cancellation )
30
30
* ` cancellation_token `
31
31
* ` cancellation_source `
32
32
* ` cancellation_registration `
33
33
* Schedulers and I/O
34
- * ` static_thread_pool `
35
- * ` io_service `
36
- * ` io_work_scope `
37
- * ` file ` , ` readable_file ` , ` writable_file `
38
- * ` read_only_file ` , ` write_only_file ` , ` read_write_file `
39
- Networking
40
- * ` socket `
41
- * ` ip_address ` , ` ipv4_address ` , ` ipv6_address `
42
- * ` ip_endpoint ` , ` ipv4_endpoint ` , ` ipv6_endpoint `
34
+ * [ ` static_thread_pool ` ] ( #static_thread_pool )
35
+ * [ ` io_service ` and ` io_work_scope ` ] ( #io_service-and-io_work_scope )
36
+ * [ ` file ` , ` readable_file ` , ` writable_file ` ] ( #file-readable_file-writable_file )
37
+ * [ ` read_only_file ` , ` write_only_file ` , ` read_write_file ` ] ( #read_only_file-write_only_file-read_write_file )
38
+ * Networking
39
+ * [ ` socket ` ] ( #socket )
40
+ * [ ` ip_address ` , ` ipv4_address ` , ` ipv6_address ` ] ( #ip_address-ipv4_address-ipv6_address )
41
+ * [ ` ip_endpoint ` , ` ipv4_endpoint ` , ` ipv6_endpoint ` ] ( #ip_endpoint-ipv4_endpoint-ipv6_endpoint )
43
42
* Metafunctions
44
- * ` is_awaitable<T> `
45
- * ` awaitable_traits<T> `
43
+ * [ ` is_awaitable<T> ` ] ( #is_awaitablet )
44
+ * [ ` awaitable_traits<T> ` ] ( #awaitable_traitst )
46
45
* Concepts
47
- * ` Awaitable<T> `
48
- * ` Awaiter<T> `
49
- * ` Scheduler `
50
- * ` DelayedScheduler `
46
+ * [ ` Awaitable<T> ` ] ( #Awaitablet-concept )
47
+ * [ ` Awaiter<T> ` ] ( #Awaitert-concept )
48
+ * [ ` Scheduler ` ] ( #Scheduler-concept )
49
+ * [ ` DelayedScheduler ` ] ( #DelayedScheduler-concept )
51
50
52
51
This library is an experimental library that is exploring the space of high-performance,
53
52
scalable asynchronous programming abstractions that can be built on top of the C++ coroutines
@@ -89,7 +88,7 @@ cppcoro::task<int> count_lines(std::string path)
89
88
lineCount += std::count(buffer, buffer + bytesRead, '\n');
90
89
offset += bytesRead;
91
90
} while (bytesRead > 0);
92
-
91
+
93
92
co_return lineCount;
94
93
}
95
94
@@ -98,9 +97,9 @@ cppcoro::task<> usage_example()
98
97
// Calling function creates a new task but doesn't start
99
98
// executing the coroutine yet.
100
99
cppcoro::task<int > countTask = count_lines("foo.txt");
101
-
100
+
102
101
// ...
103
-
102
+
104
103
// Coroutine is only started when we later co_await the task.
105
104
int lineCount = co_await countTask;
106
105
@@ -146,10 +145,10 @@ namespace cppcoro
146
145
// coroutine until the task completes.
147
146
//
148
147
// The 'co_await t.when_ready()' expression differs from 'co_await t' in
149
- // that when_ready() only performs synchronisation , it does not return
148
+ // that when_ready() only performs synchronization , it does not return
150
149
// the result or rethrow the exception.
151
150
//
152
- // This can be useful if you want to synchronise with the task without
151
+ // This can be useful if you want to synchronize with the task without
153
152
// the possibility of it throwing an exception.
154
153
Awaitable<void> when_ready() const noexcept;
155
154
};
@@ -258,7 +257,7 @@ namespace cppcoro
258
257
// is available.
259
258
//
260
259
// The result is not returned from the co_await expression.
261
- // This can be used to synchronise with the task without the
260
+ // This can be used to synchronize with the task without the
262
261
// possibility of the co_await expression throwing an exception.
263
262
Awaiter<void> when_ready() const noexcept;
264
263
@@ -281,7 +280,7 @@ namespace cppcoro
281
280
}
282
281
```
283
282
284
- All const-methods on ` shared_task<T> ` are safe to call concurrently with other
283
+ All const-methods on ` shared_task<T> ` are safe to call concurrently with other
285
284
const-methods on the same instance from multiple threads. It is not safe to call
286
285
non-const methods of ` shared_task<T> ` concurrently with any other method on the
287
286
same instance of a ` shared_task<T> ` .
@@ -387,7 +386,7 @@ namespace cppcoro
387
386
388
387
generator(generator&& other) noexcept;
389
388
generator& operator=(generator&& other) noexcept;
390
-
389
+
391
390
generator(const generator& other) = delete;
392
391
generator& operator=(const generator&) = delete;
393
392
@@ -428,7 +427,7 @@ of the current coroutine will resume execution to produce the next element.
428
427
429
428
The benefit of `recursive_generator<T>` over `generator<T>` for iterating over recursive data-structures is that the `iterator::operator++()`
430
429
is able to directly resume the leaf-most coroutine to produce the next element, rather than having to resume/suspend O(depth) coroutines for each element.
431
- The down-side is that there is additional overhead
430
+ The down-side is that there is additional overhead
432
431
433
432
For example:
434
433
```c++
@@ -499,7 +498,7 @@ namespace cppcoro
499
498
using value_type = std::remove_reference_t<T>;
500
499
using reference = value_type&;
501
500
using pointer = value_type*;
502
-
501
+
503
502
iterator(const iterator& other) noexcept;
504
503
iterator& operator=(const iterator& other) noexcept;
505
504
@@ -570,7 +569,7 @@ consumer coroutine is executing a `co_await` expression waiting for the next ite
570
569
571
570
This is a simple manual-reset event type that supports only a single
572
571
coroutine awaiting it at a time.
573
- This can be used to
572
+ This can be used to
574
573
575
574
API Summary:
576
575
``` c++
@@ -617,7 +616,7 @@ void producer()
617
616
618
617
## ` single_consumer_async_auto_reset_event `
619
618
620
- This class provides an async synchronisation primitive that allows a single coroutine to
619
+ This class provides an async synchronization primitive that allows a single coroutine to
621
620
wait until the event is signalled by a call to the ` set() ` method.
622
621
623
622
Once the coroutine that is awaiting the event is released by either a prior or subsequent call to ` set() `
@@ -764,7 +763,7 @@ cppcoro::task<> add_item(std::string value)
764
763
765
764
## ` async_manual_reset_event `
766
765
767
- A manual-reset event is a coroutine/thread-synchronisation primitive that allows one or more threads
766
+ A manual-reset event is a coroutine/thread-synchronization primitive that allows one or more threads
768
767
to wait until the event is signalled by a thread that calls ` set() ` .
769
768
770
769
The event is in one of two states; * 'set'* and * 'not set'* .
@@ -845,7 +844,7 @@ namespace cppcoro
845
844
846
845
## `async_auto_reset_event`
847
846
848
- An auto-reset event is a coroutine/thread-synchronisation primitive that allows one or more threads
847
+ An auto-reset event is a coroutine/thread-synchronization primitive that allows one or more threads
849
848
to wait until the event is signalled by a thread by calling `set()`.
850
849
851
850
Once a coroutine that is awaiting the event is released by either a prior or subsequent call to `set()`
@@ -914,7 +913,7 @@ namespace cppcoro
914
913
915
914
## ` async_latch `
916
915
917
- An async latch is a synchronisation primitive that allows coroutines to asynchronously
916
+ An async latch is a synchronization primitive that allows coroutines to asynchronously
918
917
wait until a counter has been decremented to zero.
919
918
920
919
The latch is a single-use object. Once the counter reaches zero the latch becomes 'ready'
@@ -954,7 +953,7 @@ namespace cppcoro
954
953
955
954
## `sequence_barrier`
956
955
957
- A `sequence_barrier` is a synchronisation primitive that allows a single-producer
956
+ A `sequence_barrier` is a synchronization primitive that allows a single-producer
958
957
and multiple consumers to coordinate with respect to a monotonically increasing
959
958
sequence number.
960
959
@@ -985,7 +984,7 @@ namespace cppcoro
985
984
986
985
// Wait until the specified targetSequence number has been published.
987
986
//
988
- // If the operation does not complete synchonously then the awaiting
987
+ // If the operation does not complete synchronously then the awaiting
989
988
// coroutine is resumed on the specified scheduler. Otherwise, the
990
989
// coroutine continues without suspending.
991
990
//
@@ -1003,7 +1002,7 @@ namespace cppcoro
1003
1002
1004
1003
## ` single_producer_sequencer `
1005
1004
1006
- A ` single_producer_sequencer ` is a synchronisation primitived that can be used to
1005
+ A ` single_producer_sequencer ` is a synchronization primitive that can be used to
1007
1006
coordinate access to a ring-buffer for a single producer and one or more consumers.
1008
1007
1009
1008
A producer first acquires one or more slots in a ring-buffer, writes to the ring-buffer
@@ -1053,7 +1052,7 @@ namespace cppcoro
1053
1052
SEQUENCE last_published() const noexcept;
1054
1053
1055
1054
template<typename SCHEDULER>
1056
- [[nodsicard ]]
1055
+ [[nodiscard ]]
1057
1056
Awaitable<SEQUENCE> wait_until_published(
1058
1057
SEQUENCE targetSequence,
1059
1058
SCHEDULER& scheduler) const noexcept;
@@ -1091,7 +1090,7 @@ task<void> producer(
1091
1090
// Populate the message.
1092
1091
auto& msg = buffer[seq & indexMask];
1093
1092
msg.id = i;
1094
- msg.timestammp = steady_clock::now();
1093
+ msg.timestamp = steady_clock::now();
1095
1094
msg.data = s;
1096
1095
1097
1096
// Publish the message.
@@ -1146,7 +1145,7 @@ task<void> example(io_service& ioSvc, static_thread_pool& threadPool)
1146
1145
1147
1146
## `multi_producer_sequencer`
1148
1147
1149
- The `multi_producer_sequencer` class is a synchronisation primitive that coordinates
1148
+ The `multi_producer_sequencer` class is a synchronization primitive that coordinates
1150
1149
access to a ring-buffer for multiple producers and one or more consumers.
1151
1150
1152
1151
For a single-producer variant see the `single_producer_sequencer` class.
@@ -1208,7 +1207,7 @@ namespace cppcoro
1208
1207
}
1209
1208
```
1210
1209
1211
- ## ` cancellation_token `
1210
+ ## Cancellation
1212
1211
1213
1212
A ` cancellation_token ` is a value that can be passed to a function that allows the caller to subsequently communicate a request to cancel the operation to that function.
1214
1213
@@ -1399,7 +1398,7 @@ namespace cppcoro
1399
1398
1400
1399
// Return an operation that can be awaited by a coroutine.
1401
1400
//
1402
- //
1401
+ //
1403
1402
[[nodiscard]]
1404
1403
schedule_operation schedule() noexcept;
1405
1404
@@ -1450,7 +1449,7 @@ cppcoro::task<double> dot_product(static_thread_pool& tp, double a[], double b[]
1450
1449
}
1451
1450
```
1452
1451
1453
- ## ` io_service `
1452
+ ## ` io_service ` and ` io_work_scope `
1454
1453
1455
1454
The ` io_service ` class provides an abstraction for processing I/O completion events
1456
1455
from asynchronous I/O operations.
@@ -1654,7 +1653,7 @@ int main()
1654
1653
1655
1654
### ` io_service ` as a scheduler
1656
1655
1657
- An ` io_sevice ` class implements the interfaces for the ` Scheduler ` and ` DelayedScheduler ` concepts.
1656
+ An ` io_service ` class implements the interfaces for the ` Scheduler ` and ` DelayedScheduler ` concepts.
1658
1657
1659
1658
This allows a coroutine to suspend execution on the current thread and schedule itself for resumption
1660
1659
on an I/O thread associated with a particular ` io_service ` object.
@@ -2045,7 +2044,7 @@ namespace cppcoro::net
2045
2044
2046
2045
constexpr const bytes_t& bytes() const;
2047
2046
2048
- cosntexpr std::uint32_t to_integer() const;
2047
+ constexpr std::uint32_t to_integer() const;
2049
2048
2050
2049
static constexpr ipv4_address loopback();
2051
2050
@@ -2232,7 +2231,7 @@ namespace cppcoro::net
2232
2231
2233
2232
## ` sync_wait() `
2234
2233
2235
- The ` sync_wait() ` function can be used to synchronously wait until the specified ` awaitable `
2234
+ The ` sync_wait() ` function can be used to synchronously wait until the specified ` awaitable `
2236
2235
completes.
2237
2236
2238
2237
The specified awaitable will be ` co_await ` ed on current thread inside a newly created coroutine.
@@ -2242,7 +2241,7 @@ the `co_await` expression or rethrow the exception if the `co_await` expression
2242
2241
an unhandled exception.
2243
2242
2244
2243
The ` sync_wait() ` function is mostly useful for starting a top-level task from within ` main() `
2245
- and waiting until the task finishes, in practise it is the only way to start the first/top-level
2244
+ and waiting until the task finishes, in practice it is the only way to start the first/top-level
2246
2245
` task ` .
2247
2246
2248
2247
API Summary:
@@ -2313,7 +2312,7 @@ The result of `co_await`ing the returned awaitable is a `std::tuple` or `std::ve
2313
2312
of ` when_all_task<RESULT> ` objects. These objects allow you to obtain the result (or exception)
2314
2313
of each input awaitable separately by calling the ` when_all_task<RESULT>::result() `
2315
2314
method of the corresponding output task.
2316
- This allows the caller to concurrently await multiple awaitables and synchronise on
2315
+ This allows the caller to concurrently await multiple awaitables and synchronize on
2317
2316
their completion while still retaining the ability to subsequently inspect the results of
2318
2317
each of the ` co_await ` operations for success/failure.
2319
2318
@@ -3081,7 +3080,7 @@ See below.
3081
3080
3082
3081
You can also use the bleeding-edge Clang version by building Clang from source yourself.
3083
3082
3084
- See instructions here:
3083
+ See instructions here:
3085
3084
3086
3085
To do this you will need to install the following pre-requisites:
3087
3086
```
0 commit comments