Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions .githooks/readme-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@
**libcoro** is meant to provide low level coroutine constructs for building larger applications, the current focus is around high performance networking coroutine support.

## Overview
* C++20 coroutines!
* Modern Safe C++20 API
* Higher level coroutine constructs
** coro::task<T>
** coro::generator<T>
** coro::event
** coro::latch
** coro::mutex
** coro::sync_wait(awaitable)
*** coro::when_all(awaitable...)
* Schedulers
** coro::thread_pool for coroutine cooperative multitasking
** coro::io_scheduler for driving i/o events, uses thread_pool
*** epoll driver implemented
*** io_uring driver planned (will be required for file i/o)
* Coroutine Networking
** coro::net::dns_resolver for async dns, leverages libc-ares
** coro::tcp_client and coro::tcp_server
** coro::udp_peer
* C++20 coroutines!
* Modern Safe C++20 API
* Higher level coroutine constructs
- coro::task<T>
- coro::generator<T>
- coro::event
- coro::latch
- coro::mutex
- coro::sync_wait(awaitable)
- coro::when_all_awaitabe(awaitable...) -> coro::task<T>...
- coro::when_all(awaitable...) -> T... (Future)
* Schedulers
- coro::thread_pool for coroutine cooperative multitasking
- coro::io_scheduler for driving i/o events, uses thread_pool for coroutine execution
- epoll driver
- io_uring driver (Future, will be required for async file i/o)
* Coroutine Networking
- coro::net::dns_resolver for async dns, leverages libc-ares
- coro::net::tcp_client and coro::net::tcp_server
- coro::net::udp_peer

### A note on co_await
Its important to note with coroutines that depending on the construct used _any_ `co_await` has the
Expand Down Expand Up @@ -104,6 +105,7 @@ This project uses gitsubmodules, to properly checkout this project use:

This project depends on the following projects:
* [libc-ares](https://github.com/c-ares/c-ares) For async DNS resolver.
* [catch2](https://github.com/catchorg/Catch2) For testing.

#### Building
mkdir Release && cd Release
Expand Down Expand Up @@ -155,13 +157,12 @@ target_link_libraries(${PROJECT_NAME} PUBLIC libcoro)
#### Tests
The tests will automatically be run by github actions on creating a pull request. They can also be ran locally:

# Invoke via cmake:
# Invoke via cmake with all output from the tests displayed to console:
ctest -VV

# Or invoke directly, can pass the name of tests to execute, the framework used is catch2
# catch2 supports '*' wildcards to run multiple tests or comma delimited ',' test names.
# The below will run all tests with "tcp_server" prefix in their test name.
./Debug/test/libcoro_test "tcp_server*"
# Or invoke directly, can pass the name of tests to execute, the framework used is catch2.
# Tests are tagged with their group, below is howt o run all of the coro::net::tcp_server tests:
./Debug/test/libcoro_test "[tcp_server]"

### Support

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ set(LIBCORO_SOURCE_FILES
inc/coro/poll.hpp
inc/coro/shutdown.hpp
inc/coro/sync_wait.hpp src/sync_wait.cpp
inc/coro/task_container.hpp src/task_container.cpp
inc/coro/task.hpp
inc/coro/thread_pool.hpp src/thread_pool.cpp
inc/coro/when_all.hpp
Expand Down
49 changes: 25 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,26 @@
**libcoro** is meant to provide low level coroutine constructs for building larger applications, the current focus is around high performance networking coroutine support.

## Overview
* C++20 coroutines!
* Modern Safe C++20 API
* Higher level coroutine constructs
** coro::task<T>
** coro::generator<T>
** coro::event
** coro::latch
** coro::mutex
** coro::sync_wait(awaitable)
*** coro::when_all(awaitable...)
* Schedulers
** coro::thread_pool for coroutine cooperative multitasking
** coro::io_scheduler for driving i/o events, uses thread_pool
*** epoll driver implemented
*** io_uring driver planned (will be required for file i/o)
* Coroutine Networking
** coro::net::dns_resolver for async dns, leverages libc-ares
** coro::tcp_client and coro::tcp_server
** coro::udp_peer
* C++20 coroutines!
* Modern Safe C++20 API
* Higher level coroutine constructs
- coro::task<T>
- coro::generator<T>
- coro::event
- coro::latch
- coro::mutex
- coro::sync_wait(awaitable)
- coro::when_all_awaitabe(awaitable...) -> coro::task<T>...
- coro::when_all(awaitable...) -> T... (Future)
* Schedulers
- coro::thread_pool for coroutine cooperative multitasking
- coro::io_scheduler for driving i/o events, uses thread_pool for coroutine execution
- epoll driver
- io_uring driver (Future, will be required for async file i/o)
* Coroutine Networking
- coro::net::dns_resolver for async dns, leverages libc-ares
- coro::net::tcp_client and coro::net::tcp_server
- coro::net::udp_peer

### A note on co_await
Its important to note with coroutines that depending on the construct used _any_ `co_await` has the
Expand Down Expand Up @@ -178,6 +179,7 @@ This project uses gitsubmodules, to properly checkout this project use:

This project depends on the following projects:
* [libc-ares](https://github.com/c-ares/c-ares) For async DNS resolver.
* [catch2](https://github.com/catchorg/Catch2) For testing.

#### Building
mkdir Release && cd Release
Expand Down Expand Up @@ -229,13 +231,12 @@ target_link_libraries(${PROJECT_NAME} PUBLIC libcoro)
#### Tests
The tests will automatically be run by github actions on creating a pull request. They can also be ran locally:

# Invoke via cmake:
# Invoke via cmake with all output from the tests displayed to console:
ctest -VV

# Or invoke directly, can pass the name of tests to execute, the framework used is catch2
# catch2 supports '*' wildcards to run multiple tests or comma delimited ',' test names.
# The below will run all tests with "tcp_server" prefix in their test name.
./Debug/test/libcoro_test "tcp_server*"
# Or invoke directly, can pass the name of tests to execute, the framework used is catch2.
# Tests are tagged with their group, below is howt o run all of the coro::net::tcp_server tests:
./Debug/test/libcoro_test "[tcp_server]"

### Support

Expand Down
1 change: 1 addition & 0 deletions inc/coro/coro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
#include "coro/mutex.hpp"
#include "coro/sync_wait.hpp"
#include "coro/task.hpp"
#include "coro/task_container.hpp"
#include "coro/thread_pool.hpp"
#include "coro/when_all.hpp"
11 changes: 10 additions & 1 deletion inc/coro/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

namespace coro
{
class thread_pool;

/**
* Event is a manully triggered thread safe signal that can be co_await()'ed by multiple awaiters.
* Each awaiter should co_await the event and upon the event being set each awaiter will have their
Expand Down Expand Up @@ -44,10 +46,17 @@ class event
auto is_set() const noexcept -> bool { return m_state.load(std::memory_order_acquire) == this; }

/**
* Sets this event and resumes all awaiters.
* Sets this event and resumes all awaiters. Note that all waiters will be resumed onto this
* thread of execution.
*/
auto set() noexcept -> void;

/**
* Sets this event and resumes all awaiters onto the given thread pool. This will distribute
* the waiters across the thread pools threads.
*/
auto set(coro::thread_pool& tp) noexcept -> void;

struct awaiter
{
/**
Expand Down
Loading