Skip to content

Commit

Permalink
Add support for Visual Studio 2019 (v142, /std:c++latest)
Browse files Browse the repository at this point in the history
Replace <experimental/coroutine> with <coroutine>
Replace std::experimental:: with std::
  • Loading branch information
mriccobene committed Jan 7, 2021
1 parent a87e97f commit 92c9915
Show file tree
Hide file tree
Showing 49 changed files with 708 additions and 202 deletions.
42 changes: 26 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Warning

This repository [mriccobene/cppcoro](https://github.com/andreasbuhr/cppcoro) is a fork of the original [cppcoro library](https://github.com/lewissbaker/cppcoro) library.

The differences to the original cppcoro are:
* Replace <experimental/coroutine> with <coroutine>
* Replace std::experimental:: with std::
* Add Visual Studio 2019 project (v142, /std:c++latest)


# CppCoro - A coroutine library for C++

The 'cppcoro' library provides a large set of general-purpose primitives for making use of the coroutines TS proposal described in [N4680](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4680.pdf).
Expand Down Expand Up @@ -714,15 +724,15 @@ namespace cppcoro
{
public:
bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
bool await_suspend(std::coroutine_handle<> awaiter) noexcept;
void await_resume() const noexcept;
};

class async_mutex_scoped_lock_operation
{
public:
bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
bool await_suspend(std::coroutine_handle<> awaiter) noexcept;
[[nodiscard]] async_mutex_lock await_resume() const noexcept;
};

Expand Down Expand Up @@ -836,7 +846,7 @@ namespace cppcoro
async_manual_reset_event_operation(async_manual_reset_event& event) noexcept;

bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
bool await_suspend(std::coroutine_handle<> awaiter) noexcept;
void await_resume() const noexcept;
};
}
Expand Down Expand Up @@ -904,7 +914,7 @@ namespace cppcoro
async_auto_reset_event_operation(const async_auto_reset_event_operation& other) noexcept;
bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
bool await_suspend(std::coroutine_handle<> awaiter) noexcept;
void await_resume() const noexcept;
};
Expand Down Expand Up @@ -1389,7 +1399,7 @@ namespace cppcoro
schedule_operation(static_thread_pool* tp) noexcept;
bool await_ready() noexcept;
bool await_suspend(std::experimental::coroutine_handle<> h) noexcept;
bool await_suspend(std::coroutine_handle<> h) noexcept;
bool await_resume() noexcept;
private:
Expand Down Expand Up @@ -1546,7 +1556,7 @@ namespace cppcoro
schedule_operation& operator=(const schedule_operation&) noexcept;

bool await_ready() const noexcept;
void await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
void await_suspend(std::coroutine_handle<> awaiter) noexcept;
void await_resume() noexcept;
};

Expand All @@ -1560,7 +1570,7 @@ namespace cppcoro
timed_schedule_operation& operator=(timed_schedule_operation&&) = delete;

bool await_ready() const noexcept;
void await_suspend(std::experimental::coroutine_handle<> awaiter);
void await_suspend(std::coroutine_handle<> awaiter);
void await_resume();
};

Expand Down Expand Up @@ -1591,12 +1601,12 @@ Example:
#include <cppcoro/io_service.hpp>
#include <cppcoro/read_only_file.hpp>
#include <experimental/filesystem>
#include <filesystem>
#include <memory>
#include <algorithm>
#include <iostream>
namespace fs = std::experimental::filesystem;
namespace fs = std::filesystem;
cppcoro::task<std::uint64_t> count_lines(cppcoro::io_service& ioService, fs::path path)
{
Expand Down Expand Up @@ -1740,7 +1750,7 @@ namespace cppcoro
file_read_operation(file_read_operation&& other) noexcept;
bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter);
bool await_suspend(std::coroutine_handle<> awaiter);
std::size_t await_resume();
};
Expand All @@ -1752,7 +1762,7 @@ namespace cppcoro
file_write_operation(file_write_operation&& other) noexcept;
bool await_ready() const noexcept;
bool await_suspend(std::experimental::coroutine_handle<> awaiter);
bool await_suspend(std::coroutine_handle<> awaiter);
std::size_t await_resume();
};
Expand All @@ -1774,7 +1784,7 @@ namespace cppcoro
[[nodiscard]]
static read_only_file open(
io_service& ioService,
const std::experimental::filesystem::path& path,
const std::filesystem::path& path,
file_share_mode shareMode = file_share_mode::read,
file_buffering_mode bufferingMode = file_buffering_mode::default_);

Expand All @@ -1787,7 +1797,7 @@ namespace cppcoro
[[nodiscard]]
static write_only_file open(
io_service& ioService,
const std::experimental::filesystem::path& path,
const std::filesystem::path& path,
file_open_mode openMode = file_open_mode::create_or_open,
file_share_mode shareMode = file_share_mode::none,
file_buffering_mode bufferingMode = file_buffering_mode::default_);
Expand All @@ -1801,7 +1811,7 @@ namespace cppcoro
[[nodiscard]]
static read_write_file open(
io_service& ioService,
const std::experimental::filesystem::path& path,
const std::filesystem::path& path,
file_open_mode openMode = file_open_mode::create_or_open,
file_share_mode shareMode = file_share_mode::none,
file_buffering_mode bufferingMode = file_buffering_mode::default_);
Expand Down Expand Up @@ -2794,7 +2804,7 @@ coroutine.

A type that satisfies `Awaiter<T>` must have, for an instance of the type, `awaiter`:
- `awaiter.await_ready()` -> `bool`
- `awaiter.await_suspend(std::experimental::coroutine_handle<void>{})` -> `void` or `bool` or `std::experimental::coroutine_handle<P>` for some `P`.
- `awaiter.await_suspend(std::coroutine_handle<void>{})` -> `void` or `bool` or `std::coroutine_handle<P>` for some `P`.
- `awaiter.await_resume()` -> `T`

Any type that implements the `Awaiter<T>` concept also implements the `Awaitable<T>` concept.
Expand Down Expand Up @@ -3125,7 +3135,7 @@ ninja install-clang \

### Building libc++

The cppcoro project requires libc++ as it contains the `<experimental/coroutine>`
The cppcoro project requires libc++ as it contains the `<coroutine>`
header required to use C++ coroutines under Clang.

Checkout `libc++` + `llvm`:
Expand Down
6 changes: 3 additions & 3 deletions include/cppcoro/async_auto_reset_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef CPPCORO_ASYNC_AUTO_RESET_EVENT_HPP_INCLUDED
#define CPPCORO_ASYNC_AUTO_RESET_EVENT_HPP_INCLUDED

#include <experimental/coroutine>
#include <coroutine>
#include <atomic>
#include <cstdint>

Expand Down Expand Up @@ -80,7 +80,7 @@ namespace cppcoro
async_auto_reset_event_operation(const async_auto_reset_event_operation& other) noexcept;

bool await_ready() const noexcept { return m_event == nullptr; }
bool await_suspend(std::experimental::coroutine_handle<> awaiter) noexcept;
bool await_suspend(std::coroutine_handle<> awaiter) noexcept;
void await_resume() const noexcept {}

private:
Expand All @@ -89,7 +89,7 @@ namespace cppcoro

const async_auto_reset_event* m_event;
async_auto_reset_event_operation* m_next;
std::experimental::coroutine_handle<> m_awaiter;
std::coroutine_handle<> m_awaiter;
std::atomic<std::uint32_t> m_refCount;

};
Expand Down
Loading

0 comments on commit 92c9915

Please sign in to comment.