On 24 Aug 2015 at 11:22, Andreas Schäfer wrote:
I'm trying to run a benchmark from the documentation (see attached
afio.cpp). Compilation works fine (what was the reason for leaving out
the includes?), but the program then deadlocks in line 280:
finished_waiter.wait();
This is how I compiled, linked:
time g++ -std=c++11 afio.cpp -Iboost.afio/include/ -Iboost.afio -lboost_system -lpthread -lboost_filesystem -ldl -o afio && echo go && ./afio foo
I'm surely missing something obvious. Could you help me?
You weren't missing anything obvious. The problem was that the
find_in_files_afio.cpp code was wrong. Here is the fix:
auto enumeration=dispatcher->enumerate(enumerate_req(
dispatcher->op_from_scheduled_id(id),
metadata_flags::size, 1000));
+ future<> enumeration_op(enumeration);
auto
listing=std::make_shared
,
bool>>>(std::move(enumeration));
- auto enumeration_done=dispatcher->completion(enumeration,
+ auto enumeration_done=dispatcher->completion(enumeration_op,
make_pair(async_op_flags::none,
std::functiondispatcher::completion_t(
std::bind(&find_in_files::dir_enumerated, this,
What was happening was we were moving the future named enumeration
into make_shared, and then unsurprisingly attempting to schedule a
continuation on an empty input future did not work because the
continuation fired before the enumerate!
The fix above takes a future<void> slice of the enumeration
future<T>. That solves the problem.
find_in_files_afio.cpp is still written using the old v1.0 era API
which many said was hard to use, and I guess they proved it is true
by me making the boo boo above. In the v1.4 API you'd simply call
enumeration.then(callable).
If you go fetch the develop branch and use
https://github.com/BoostGSoC13/boost.afio/blob/develop/example/find_in
_files_afio.cpp, you should now find the example working perfectly (I
tested it on Windows here).
Niall
--
ned Productions Limited Consulting
http://www.nedproductions.biz/
http://ie.linkedin.com/in/nialldouglas/