I try to work with boost thread futures. So as shown here we can get shared future from packaged task.
So I try such function on linux:
template <class task_return_t>
void pool_item( boost::shared_ptr< boost::packaged_task<task_return_t> > pt)
{
boost::shared_future<task_return_t> fi= pt->get_future(); // error
//...
but I get error calling it:
../../src/cf-util/thread_pool.h: In member function ‘void thread_pool::pool_item(boost::shared_ptr<boost::packaged_task<R> >) [with task_return_t = void]’:
../../src/cf-util/thread_pool.h:64:3: instantiated from ‘void thread_pool::post(boost::shared_ptr<boost::packaged_task<R> >) [with task_return_t = void]’
../../src/cf-server/server.cpp:39:27: instantiated from here
../../src/cf-util/thread_pool.h:124:58: error: conversion from ‘boost::unique_future<void>’ to non-scalar type ‘boost::shared_future<void>’ requested
I did not take any futures from that task before. all source code, place where I do call from, my thread pool that is being called. And on Windows under Visual Studio 2010 it compiles and works perfectly.
What shall I do? how to fix or get around this error?