Skip to content

Commit

Permalink
为支持async_call而做调整
Browse files Browse the repository at this point in the history
  • Loading branch information
tearshark committed Jul 7, 2020
1 parent 9a0d4d4 commit db31c6b
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions example/tostring_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <iostream>

#include "modern_callback.h"
#include "async_wrapper.hpp"

//原旨主义的异步函数,其回调写法大致如下
template<typename _Input_t, typename _Callable_t>
Expand All @@ -17,13 +16,6 @@ void tostring_async_originalism(_Input_t&& value, _Callable_t&& token)
callback(std::to_string(value));
}).detach();
}
void tostring_async_originalism2(int value, std::function<void(std::string)>&& token)
{
std::thread([callback = std::move(token), value = std::forward<_Input_t>(value)]
{
callback(std::to_string(value));
}).detach();
}

//使用原旨主义的方式扩展异步方法来支持future
template<typename _Input_t>
Expand Down Expand Up @@ -121,9 +113,6 @@ static void example_future()

std::future<std::string> f2 = tostring_async(6.0f, std_future);
std::cout << f2.get() << std::endl;

std::future<std::string> f3 = async_call(&tostring_async_originalism2, 99, placeholder::_cb(std_future));
std::cout << f3.get() << std::endl;
}

#include "librf.h"
Expand Down

0 comments on commit db31c6b

Please sign in to comment.