/** * Standin for C++0x's std::async * (C) 2009 Jack Lloyd * * Distributed under the terms of the Botan license */ #ifndef BOTAN_ASYNC_H__ #define BOTAN_ASYNC_H__ #include #include namespace Botan { /** * A simple version of std::async (as it is not in GCC 4.5) * Will be removed once GCC supports it natively */ template auto std_async(F f) -> std::future { typedef decltype(f()) result_type; std::packaged_task task(std::move(f)); std::future future = task.get_future(); std::thread thread(std::move(task)); thread.detach(); return future; } } #endif