views:

413

answers:

1

Hi,

I am working on a Boost thread pool.

I have a structure like this:

class SimThreadPool
{
    static SimThreadPool* getInstance();

   boost::threadpool::prio_pool& getThreadPool() { return mThreadPool; }

    simTerrain::SimThreadPool::SimThreadPool()
    : mThreadPool(boost::threadpool::fifo_pool(1))
    {

    }

    boost::threadpool::prio_pool mThreadPool;
}

When I need a thread, I call it like this:

  SimThreadPool::getInstance()->getThreadPool().schedule(MyThread());

and it works.

The question is:

I want to convert this thread pool from fifo to priority.

I changed all my fifo\_pool to prio\_pool but I could not manage this - it didn't work. I get some errors.

Do you have any sample code for me to understand how to use a prio_pool?

I think I have to use prio_task_func instead of a class but I want to use similar algorithms for this purpose.

+1  A: 

I think you need to declare mThreadPool as:

boost::threadpool::scoped_pool<boost::threadpool::prio_pool, 0> mThreadPool;

before you use prio_task_func in your class.

Have you looked at http://sourceforge.net/projects/threadpool/ ?

DaveParillo