Line | |
---|
1 | // (C) Copyright Mac Murrett 2001. |
---|
2 | // Use, modification and distribution are subject to the |
---|
3 | // Boost Software License, Version 1.0. (See accompanying file |
---|
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
5 | |
---|
6 | // See http://www.boost.org for most recent version. |
---|
7 | |
---|
8 | #ifndef BOOST_PACKAGE_MJM012402_HPP |
---|
9 | #define BOOST_PACKAGE_MJM012402_HPP |
---|
10 | |
---|
11 | |
---|
12 | namespace boost { |
---|
13 | |
---|
14 | namespace threads { |
---|
15 | |
---|
16 | namespace mac { |
---|
17 | |
---|
18 | namespace detail { |
---|
19 | |
---|
20 | |
---|
21 | class base_package: private noncopyable |
---|
22 | { |
---|
23 | public: |
---|
24 | virtual void accept() = 0; |
---|
25 | }; |
---|
26 | |
---|
27 | template<class R> |
---|
28 | class package: public base_package |
---|
29 | { |
---|
30 | public: |
---|
31 | inline package(function<R> &rFunctor): |
---|
32 | m_rFunctor(rFunctor) |
---|
33 | { /* no-op */ } |
---|
34 | inline ~package() |
---|
35 | { /* no-op */ } |
---|
36 | |
---|
37 | virtual void accept() |
---|
38 | { m_oR = m_rFunctor(); } |
---|
39 | inline R return_value() |
---|
40 | { return(m_oR); } |
---|
41 | |
---|
42 | private: |
---|
43 | function<R> &m_rFunctor; |
---|
44 | R m_oR; |
---|
45 | }; |
---|
46 | |
---|
47 | template<> |
---|
48 | class package<void>: public base_package |
---|
49 | { |
---|
50 | public: |
---|
51 | inline package(function<void> &rFunctor): |
---|
52 | m_rFunctor(rFunctor) |
---|
53 | { /* no-op */ } |
---|
54 | inline ~package() |
---|
55 | { /* no-op */ } |
---|
56 | |
---|
57 | virtual void accept() |
---|
58 | { m_rFunctor(); } |
---|
59 | inline void return_value() |
---|
60 | { return; } |
---|
61 | |
---|
62 | private: |
---|
63 | function<void> &m_rFunctor; |
---|
64 | }; |
---|
65 | |
---|
66 | |
---|
67 | } // namespace detail |
---|
68 | |
---|
69 | } // namespace mac |
---|
70 | |
---|
71 | } // namespace threads |
---|
72 | |
---|
73 | } // namespace boost |
---|
74 | |
---|
75 | |
---|
76 | #endif // BOOST_PACKAGE_MJM012402_HPP |
---|
Note: See
TracBrowser
for help on using the repository browser.