#include <scroom/threadpool.hh>
#include <iostream>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <scroom/function-additor.hh>
#include <scroom/semaphore.hh>
#include "helpers.hh"
◆ BOOST_AUTO_TEST_CASE() [1/9]
| BOOST_AUTO_TEST_CASE |
( |
construct_0_threads |
| ) |
|
◆ BOOST_AUTO_TEST_CASE() [2/9]
| BOOST_AUTO_TEST_CASE |
( |
construct_1_threads |
| ) |
|
◆ BOOST_AUTO_TEST_CASE() [3/9]
| BOOST_AUTO_TEST_CASE |
( |
construct_2_threads |
| ) |
|
185 const int expected = 2;
186 #ifndef MULTITHREADING
◆ BOOST_AUTO_TEST_CASE() [4/9]
| BOOST_AUTO_TEST_CASE |
( |
schedule_future |
| ) |
|
206 boost::unique_future<int> result(pool.schedule<
int>(boost::bind(no_op<int>, &a, 42)));
209 BOOST_CHECK(!result.is_ready());
◆ BOOST_AUTO_TEST_CASE() [5/9]
| BOOST_AUTO_TEST_CASE |
( |
schedule_shared_pointer |
| ) |
|
◆ BOOST_AUTO_TEST_CASE() [6/9]
| BOOST_AUTO_TEST_CASE |
( |
schedule_shared_pointer_with_future |
| ) |
|
224 BOOST_CHECK(!result.is_ready());
◆ BOOST_AUTO_TEST_CASE() [7/9]
| BOOST_AUTO_TEST_CASE |
( |
verify_threadcount |
| ) |
|
240 const int expected = boost::thread::hardware_concurrency();
241 #ifndef MULTITHREADING
◆ BOOST_AUTO_TEST_CASE() [8/9]
| BOOST_AUTO_TEST_CASE |
( |
work_gets_done |
| ) |
|
141 pool.schedule(
clear(&s));
◆ BOOST_AUTO_TEST_CASE() [9/9]
| BOOST_AUTO_TEST_CASE |
( |
work_gets_done_by_prio |
| ) |
|
◆ has_at_least_n_threads()
| bool has_at_least_n_threads |
( |
ThreadPool * |
pool, |
|
|
int |
count_ |
|
) |
| |
93 std::vector<Semaphore*> semaphores(count_);
94 for(
int i = 0; i < count_; i++)
99 for(
int i = 0; i < count_ - 1; i++)
118 for(
int i = 1; i < count_; i++)
Referenced by has_exactly_n_threads().
◆ has_exactly_n_threads()
| bool has_exactly_n_threads |
( |
ThreadPool * |
pool, |
|
|
int |
count |
|
) |
| |
◆ long_timeout()
| const millisec long_timeout |
( |
2000 |
| ) |
|
◆ no_op()
◆ short_timeout()
| const millisec short_timeout |
( |
250 |
| ) |
|
boost::shared_ptr< ThreadPool > Ptr
Definition: threadpool.hh:169
const millisec long_timeout(2000)
boost::function< void()> clear(Semaphore *s)
Definition: helpers.cc:29
bool has_exactly_n_threads(ThreadPool *pool, int count)
Definition: threadpool-tests.cc:126
Definition: threadpool.hh:46
const millisec short_timeout(250)
BOOST_CHECK_EQUAL(sample.expectedColors, originalColormap->colors.size())
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
Definition: semaphore.hh:15
@ PRIO_HIGH
Definition: threadpool.hh:28
boost::function< void()> pass(Semaphore *s)
Definition: helpers.cc:27
static Ptr create(int &i)
Definition: boost-bind.cc:38
void V()
Definition: semaphore.hh:77
@ PRIO_NORMAL
Definition: threadpool.hh:29
void schedule(boost::function< void()> const &fn, int priority=defaultPriority, const Queue::Ptr &queue=defaultQueue())
Definition: threadpoolimpl.cc:342
bool has_at_least_n_threads(ThreadPool *pool, int count_)
Definition: threadpool-tests.cc:86
Definition: threadpool-tests.cc:53