1
1
2
2
// Copyright 2010 Dean Michael Berris.
3
3
// Copyright 2012 Google, Inc.
4
+ // Copyright (c) Glyn Matthews 2012.
4
5
// Distributed under the Boost Software License, Version 1.0.
5
6
// (See accompanying file LICENSE_1_0.txt or copy at
6
7
// http://www.boost.org/LICENSE_1_0.txt)
7
8
8
9
#ifdef BUILD_SHARED_LIBS
9
10
# define BOOST_TEST_DYN_LINK
10
11
#endif
11
- #define BOOST_TEST_MODULE utils thread pool test
12
+ #define BOOST_TEST_MODULE thread pool test
12
13
#include < boost/config/warning_disable.hpp>
13
14
#include < boost/test/unit_test.hpp>
14
- #include < network/utils /thread_pool.hpp>
15
+ #include < network/concurrency /thread_pool.hpp>
15
16
#include < boost/bind.hpp>
16
17
17
- using namespace network ;
18
+ using network::concurrency::thread_pool ;
18
19
19
20
// This test specifies the requirements for a thread pool interface. At the
20
21
// very least any thread pool implementation should be able to pass the simple
@@ -25,29 +26,29 @@ using namespace network;
25
26
//
26
27
27
28
BOOST_AUTO_TEST_CASE ( default_constructor ) {
28
- utils:: thread_pool pool;
29
- BOOST_CHECK_EQUAL (pool.thread_count (), std::size_t (1 ));
29
+ thread_pool pool;
30
+ BOOST_CHECK_EQUAL (pool.thread_count (), std::size_t (1 ));
30
31
}
31
32
32
33
struct foo {
33
- foo () : val_(0 ) {}
34
- void bar (int val) {
35
- val_ += val;
36
- }
37
- int const val () const {
38
- return val_;
39
- }
34
+ foo () : val_(0 ) {}
35
+ void bar (int val) {
36
+ val_ += val;
37
+ }
38
+ int const val () const {
39
+ return val_;
40
+ }
40
41
protected:
41
- int val_;
42
+ int val_;
42
43
};
43
44
44
45
BOOST_AUTO_TEST_CASE ( post_work ) {
45
- foo instance;
46
- {
47
- utils:: thread_pool pool;
48
- BOOST_CHECK_NO_THROW (pool.post (boost::bind (&foo::bar, &instance, 1 )));
49
- BOOST_CHECK_NO_THROW (pool.post (boost::bind (&foo::bar, &instance, 2 )));
50
- // require that pool is destroyed here, RAII baby
51
- }
52
- BOOST_CHECK_EQUAL (instance.val (), 3 );
46
+ foo instance;
47
+ {
48
+ thread_pool pool;
49
+ BOOST_CHECK_NO_THROW (pool.post (boost::bind (&foo::bar, &instance, 1 )));
50
+ BOOST_CHECK_NO_THROW (pool.post (boost::bind (&foo::bar, &instance, 2 )));
51
+ // require that pool is destroyed here, RAII baby
52
+ }
53
+ BOOST_CHECK_EQUAL (instance.val (), 3 );
53
54
}
0 commit comments