How to convert Boost thread pool from fifo to priority?

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: how can I convert this thread pool from fifo to priority?

I changed all of mine fifo\_poolto , but I couldn’t do it - it didn’t work. I got some errors. prio\_pool

How can I use prio_poolin this situation?

I think I should use prio_task_funcinstead of the class, but I want to reuse existing algorithms for this purpose.

+3
source share
1 answer

, mThreadPool :

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

prio_task_func .

http://sourceforge.net/projects/threadpool/?

+1

Source: https://habr.com/ru/post/1716488/


All Articles