Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/thread/src/mac/package.hpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 18 years ago

added boost

File size: 1.5 KB
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
12namespace boost {
13
14namespace threads {
15
16namespace mac {
17
18namespace detail {
19
20
21class base_package: private noncopyable
22{
23  public:
24    virtual void accept() = 0;
25};
26
27template<class R>
28class 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
47template<>
48class 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.