"vscode:/vscode.git/clone" did not exist on "4858f3bb45ec62fab1fc32dc26eb1e2a8e1df14b"
Commit 74b3d019 authored by Paul's avatar Paul
Browse files

Formatting

parent 4f778e9f
...@@ -7,25 +7,21 @@ namespace migraph { ...@@ -7,25 +7,21 @@ namespace migraph {
struct swallow struct swallow
{ {
template<class... Ts> template <class... Ts>
swallow(Ts&&...) swallow(Ts&&...)
{} {
}
}; };
struct tracer struct tracer
{ {
tracer() tracer() {}
{}
tracer(std::ostream& s) : os(&s) tracer(std::ostream& s) : os(&s) {}
{}
bool enabled() const bool enabled() const { return os != nullptr; }
{
return os != nullptr;
}
template<class... Ts> template <class... Ts>
void operator()(const Ts&... xs) const void operator()(const Ts&... xs) const
{ {
if(os != nullptr) if(os != nullptr)
...@@ -35,8 +31,8 @@ struct tracer ...@@ -35,8 +31,8 @@ struct tracer
} }
} }
private: private:
std::ostream * os = nullptr; std::ostream* os = nullptr;
}; };
} // namespace migraph } // namespace migraph
......
...@@ -24,15 +24,19 @@ ...@@ -24,15 +24,19 @@
// An improved async, that doesn't block // An improved async, that doesn't block
template <class Function> template <class Function>
std::future<typename std::result_of<Function()>::type> detach_async(Function&& f, bool parallel=true) std::future<typename std::result_of<Function()>::type> detach_async(Function&& f,
bool parallel = true)
{ {
if(parallel){ if(parallel)
{
using result_type = typename std::result_of<Function()>::type; using result_type = typename std::result_of<Function()>::type;
std::packaged_task<result_type()> task(std::forward<Function>(f)); std::packaged_task<result_type()> task(std::forward<Function>(f));
auto fut = task.get_future(); auto fut = task.get_future();
std::thread(std::move(task)).detach(); std::thread(std::move(task)).detach();
return std::move(fut); return std::move(fut);
} else { }
else
{
return std::async(std::launch::deferred, std::move(f)); return std::async(std::launch::deferred, std::move(f));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment