Giter Site home page Giter Site logo

renestein / rstein.asynccpp Goto Github PK

View Code? Open in Web Editor NEW
30.0 4.0 4.0 2.31 MB

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

C++ 98.62% Batchfile 1.38%
coroutine task-parallel-library coroutines async await concurrency functional-task taskcompletionsource task hot-tasks

rstein.asynccpp's People

Contributors

renestein avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rstein.asynccpp's Issues

Can't co_await a std::shared_future in a c++/winrt UWP app (doesn't compile)

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);
                                                      });

`dynamic atexit destructor for 'threadPool'

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

Dealing with types without default constructors

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);
            });

Where is gtest/gtest.h?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.