Boost logo

Boost :

From: Oliver.Kowalke_at_[hidden]
Date: 2007-03-15 03:24:43


> I've made a futures implementation in the hopes of combining
> the best features from all the proposals and various
> implementations currently floating around. It is still rough
> around the edges, but is mostly covered by unit tests.
> I'm looking for input. I'd be willing to add additional
> functionality needed and progress it to the point where it
> could be formally submitted into boost if there is interest.
> It could perhaps be merged into the existing futures
> implementation in the vault to add combined groups, etc.
> I used Peter's exception_ptr code, which he said he would
> post under a boost license.
> -Braddock Gaskill

I've tested your implementation with a thread and I get sometimes an
segmentation fault (linux, gcc-4.1.0).
File future_detail.hpp line 79 causes the segmentation fault.
Regards, Oliver


#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>

#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/thread.hpp>

#include "future.hpp"

struct X
        std::string execute()
        { return "std::string X::execute()"; }

void execute(
        boost::promise< std::string > p,
        boost::function< std::string() > fn)
{ p.set( fn() ); }

int main( int argc, char *argv[])
                X x;
                boost::function< std::string() > fn(
                                & X::execute,
                                x) );
                boost::promise< std::string > p;
                boost::future< std::string > f( p);
                boost::thread t(
                                & execute,
                                fn) );

                std::cout << f.get() << std::endl;


                return EXIT_SUCCESS;
        catch ( std::exception const& e)
        { std::cerr << e.what() << std::endl; }
        catch ( ... )
        { std::cerr << "unhandled exception" << std::endl; }

        return EXIT_FAILURE;


Program terminated with signal 11, Segmentation fault.
#0 basic_string (this=0xbff79740, __str=@0x0) at
ring.h: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0 basic_string (this=0xbff79740, __str=@0x0) at
#1 0x0804d8da in boost::detail::future_impl::get<std::string>
(this=0x8055048, value=0x0) at
#2 0x0804d94b in boost::future<std::string>::get (this=0xbff796c4) at
#3 0x0804a007 in main () at

Boost list run by bdawes at, gregod at, cpdaniel at, john at