Subject: Re: [boost] [afio] Formal review of Boost.AFIO
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2015-08-24 15:48:22
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:
> 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:
+ future<> enumeration_op(enumeration);
- auto enumeration_done=dispatcher->completion(enumeration,
+ auto enumeration_done=dispatcher->completion(enumeration_op,
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
If you go fetch the develop branch and use
_files_afio.cpp, you should now find the example working perfectly (I
tested it on Windows here).
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk