renestein / rstein.asynccpp Goto Github PK
View Code? Open in Web Editor NEWThe RStein.AsyncCpp library is a set of types that should be familiar for anyone who knows the Task Parallel Library (TPL) for .NET (C#).
License: MIT License
The RStein.AsyncCpp library is a set of types that should be familiar for anyone who knows the Task Parallel Library (TPL) for .NET (C#).
License: MIT License
Do you have any idea why this is? I have set the c++ version to latest and added /await compiler flag.
I am able to co_await a std::future, so I am probably able to use a lot of Rstein.AsyncCpp already.
This doesn't compile:
Windows::Foundation::IAsyncAction MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
{
std::promise<void> promise;
promise.set_value();
std::shared_future<void> _completedFuture = promise.get_future().share();
co_await _completedFuture;
}
I get:
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\future(1034,1): error C3312: no callable 'await_resume' function found for type 'std::shared_future'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\future(1034,1): error C3312: no callable 'await_ready' function found for type 'std::shared_future'
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\future(1034,1): error C3312: no callable 'await_suspend' function found for type 'std::shared_future'
So this isn't compiling:
auto transform1 = DataFlowAsyncFactory::CreateTransformBlock<int, string>([](const int& item)-> Tasks::Task<string>
{
auto message = "int: " + to_string(item) + "\n";
cout << message;
//await async operation returning standard shared_future.
co_await GetCompletedSharedFuture();
co_return to_string(item);
});
Will you implement BufferBlock counterpart in DataFlow here? I think it's a useful feature to work together with coroutine.
CP.51: Do not use capturing lambdas that are coroutines
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cp51-do-not-use-capturing-lambdas-that-are-coroutines
I'm getting a weird exception / crash at end of runtime.
This console program produces it:
#include <RStein.AsyncCpp/Tasks/TaskCompletionSource.h>
int main()
{
RStein::AsyncCpp::Tasks::TaskCompletionSource<__int64> _tCS;
}
I had never heard of atexit() before this, and it was quite confusing. Should I ignore this crashing? Is there a work-around?
Here is the call stack for the above:
> [Inline Frame] FolderOpenerTestConsole.exe!std::thread::{dtor}() Line 95 C++
[Inline Frame] FolderOpenerTestConsole.exe!std::destroy_at(std::thread * const) Line 325 C++
[Inline Frame] FolderOpenerTestConsole.exe!std::_Default_allocator_traits<std::allocator<std::thread>>::destroy(std::allocator<std::thread> &) Line 721 C++
[Inline Frame] FolderOpenerTestConsole.exe!std::_Destroy_range(std::thread * _First, std::thread * const) Line 950 C++
[Inline Frame] FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::_Destroy(std::thread * _First, std::thread * _Last) Line 1680 C++
[Inline Frame] FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::_Tidy() Line 1764 C++
FolderOpenerTestConsole.exe!std::vector<std::thread,std::allocator<std::thread>>::~vector<std::thread,std::allocator<std::thread>>() Line 712 C++
[Inline Frame] FolderOpenerTestConsole.exe!RStein::AsyncCpp::Schedulers::SimpleThreadPool::{dtor}() Line 35 C++
FolderOpenerTestConsole.exe!`RStein::AsyncCpp::Schedulers::Scheduler::initDefaultScheduler'::`2'::`dynamic atexit destructor for 'threadPool''() C++
ucrtbase.dll!00007ffb4f4cbea0() Unknown
ucrtbase.dll!00007ffb4f4cbdb7() Unknown
ucrtbase.dll!00007ffb4f4cbd6d() Unknown
ucrtbase.dll!00007ffb4f4ca17a() Unknown
ucrtbase.dll!00007ffb4f4ca10f() Unknown
ucrtbase.dll!00007ffb4f4ca0af() Unknown
FolderOpenerTestConsole.exe!__scrt_common_main_seh() Line 295 C++
kernel32.dll!00007ffb4f5e54e0() Unknown
ntdll.dll!00007ffb5174485b() Unknown
I am trying to deal with winrt::Windows::Storage::StorageFile objects from c++/winrt . I can just wrap this type, but is there anything else I can do? Is there any hope that default constructors won't be a requirement in the future?
Doesn't compile; "no appropriate default constructor available":
auto m_folderActionBlock =
DataFlowAsyncFactory::CreateActionBlock<winrt::Windows::Storage::StorageFolder>([](const Windows::Storage::StorageFolder& item)-> Tasks::Task<void>
{
// auto message = "Final action: " + item + "\n";
// cout << message;
// await async operation returning Task.
co_await Tasks::GetCompletedTask();
//_processedItems.push_back(item);
});
I am struggling. Where is gtest.h?
Update: ok it looks like I had to include Google's testing.
BTW it's great that someone is doing a C++ equivalent of this stuff from c#, thanks.
PR in vcpkg project (merged).
microsoft/vcpkg#16380
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.