Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/thread/src/mac/remote_calls.hpp @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 6.6 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_REMOTE_CALLS_MJM012402_HPP
9#define BOOST_REMOTE_CALLS_MJM012402_HPP
10
11
12#include <boost/bind.hpp>
13
14#include "remote_call_manager.hpp"
15#include <boost/thread/detail/singleton.hpp>
16
17
18// this file contains macros to generate functions with the signatures:
19//  ReturnType st_remote_call([pascal] ReturnType (*pfnFunction)(
20//                              [Argument1Type[, Argument2Type[...]]])
21//                            [, Argument1Type oArgument1[, Argument2Type oArgument2[...]]])
22// and
23//  ReturnType dt_remote_call([pascal] ReturnType (*pfnFunction)(
24//                              [Argument1Type[, Argument2Type[...]]])
25//                            [, Argument1Type oArgument1[, Argument2Type oArgument2[...]]])
26// in other words, identical to the function pointer versions of boost::bind, but
27//  with the return type returned.  The purpose of these functions is to be able to
28//  request that a function be called at system task time or deferred task time, then
29//  sleep until it is called, and finally get back its return value.
30
31#define BOOST_REMOTE_CALL_CLASS_LIST_0
32#define BOOST_REMOTE_CALL_CLASS_LIST_1 BOOST_REMOTE_CALL_CLASS_LIST_0, class A1
33#define BOOST_REMOTE_CALL_CLASS_LIST_2 BOOST_REMOTE_CALL_CLASS_LIST_1, class A2
34#define BOOST_REMOTE_CALL_CLASS_LIST_3 BOOST_REMOTE_CALL_CLASS_LIST_2, class A3
35#define BOOST_REMOTE_CALL_CLASS_LIST_4 BOOST_REMOTE_CALL_CLASS_LIST_3, class A4
36#define BOOST_REMOTE_CALL_CLASS_LIST_5 BOOST_REMOTE_CALL_CLASS_LIST_4, class A5
37#define BOOST_REMOTE_CALL_CLASS_LIST_6 BOOST_REMOTE_CALL_CLASS_LIST_5, class A6
38#define BOOST_REMOTE_CALL_CLASS_LIST_7 BOOST_REMOTE_CALL_CLASS_LIST_6, class A7
39#define BOOST_REMOTE_CALL_CLASS_LIST_8 BOOST_REMOTE_CALL_CLASS_LIST_7, class A8
40#define BOOST_REMOTE_CALL_CLASS_LIST_9 BOOST_REMOTE_CALL_CLASS_LIST_8, class A9
41
42
43#define BOOST_REMOTE_CALL_ARGUMENT_LIST_0
44#define BOOST_REMOTE_CALL_ARGUMENT_LIST_1 BOOST_REMOTE_CALL_ARGUMENT_LIST_0  A1 oA1
45#define BOOST_REMOTE_CALL_ARGUMENT_LIST_2 BOOST_REMOTE_CALL_ARGUMENT_LIST_1, A2 oA2
46#define BOOST_REMOTE_CALL_ARGUMENT_LIST_3 BOOST_REMOTE_CALL_ARGUMENT_LIST_2, A3 oA3
47#define BOOST_REMOTE_CALL_ARGUMENT_LIST_4 BOOST_REMOTE_CALL_ARGUMENT_LIST_3, A4 oA4
48#define BOOST_REMOTE_CALL_ARGUMENT_LIST_5 BOOST_REMOTE_CALL_ARGUMENT_LIST_4, A5 oA5
49#define BOOST_REMOTE_CALL_ARGUMENT_LIST_6 BOOST_REMOTE_CALL_ARGUMENT_LIST_5, A6 oA6
50#define BOOST_REMOTE_CALL_ARGUMENT_LIST_7 BOOST_REMOTE_CALL_ARGUMENT_LIST_6, A7 oA7
51#define BOOST_REMOTE_CALL_ARGUMENT_LIST_8 BOOST_REMOTE_CALL_ARGUMENT_LIST_7, A8 oA8
52#define BOOST_REMOTE_CALL_ARGUMENT_LIST_9 BOOST_REMOTE_CALL_ARGUMENT_LIST_8, A9 oA9
53
54
55#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_0
56#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_1 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_0, oA1
57#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_2 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_1, oA2
58#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_3 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_2, oA3
59#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_4 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_3, oA4
60#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_5 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_4, oA5
61#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_6 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_5, oA6
62#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_7 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_6, oA7
63#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_8 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_7, oA8
64#define BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_9 BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_8, oA9
65
66
67#define BOOST_REMOTE_CALL_COMMA_0
68#define BOOST_REMOTE_CALL_COMMA_1 ,
69#define BOOST_REMOTE_CALL_COMMA_2 ,
70#define BOOST_REMOTE_CALL_COMMA_3 ,
71#define BOOST_REMOTE_CALL_COMMA_4 ,
72#define BOOST_REMOTE_CALL_COMMA_5 ,
73#define BOOST_REMOTE_CALL_COMMA_6 ,
74#define BOOST_REMOTE_CALL_COMMA_7 ,
75#define BOOST_REMOTE_CALL_COMMA_8 ,
76#define BOOST_REMOTE_CALL_COMMA_9 ,
77
78
79// this is the macro that ties it all together.  From here, we generate all forms of
80//  dt_remote_call and st_remote_call.
81
82#define BOOST_REMOTE_CALL(context, stack, n)                                        \
83template<class R BOOST_REMOTE_CALL_CLASS_LIST_ ## n>                                \
84inline R context ## _remote_call(stack R (*pfnF)(                                   \
85                                      BOOST_REMOTE_CALL_ARGUMENT_LIST_ ## n)        \
86                                      BOOST_REMOTE_CALL_COMMA_ ## n                 \
87                                  BOOST_REMOTE_CALL_ARGUMENT_LIST_ ## n)            \
88{                                                                                   \
89    using ::boost::detail::thread::singleton;                                       \
90    using detail::remote_call_manager;                                              \
91    function<R> oFunc(bind(pfnF BOOST_REMOTE_CALL_FUNCTION_ARGUMENT_LIST_ ## n));   \
92    remote_call_manager &rManager(singleton<remote_call_manager>::instance());      \
93    return(rManager.execute_at_ ## context(oFunc));                                 \
94}
95
96
97namespace boost {
98
99namespace threads {
100
101namespace mac {
102
103
104BOOST_REMOTE_CALL(st, , 0)
105BOOST_REMOTE_CALL(st, , 1)
106BOOST_REMOTE_CALL(st, , 2)
107BOOST_REMOTE_CALL(st, , 3)
108BOOST_REMOTE_CALL(st, , 4)
109BOOST_REMOTE_CALL(st, , 5)
110BOOST_REMOTE_CALL(st, , 6)
111BOOST_REMOTE_CALL(st, , 7)
112BOOST_REMOTE_CALL(st, , 8)
113BOOST_REMOTE_CALL(st, , 9)
114
115BOOST_REMOTE_CALL(dt, , 0)
116BOOST_REMOTE_CALL(dt, , 1)
117BOOST_REMOTE_CALL(dt, , 2)
118BOOST_REMOTE_CALL(dt, , 3)
119BOOST_REMOTE_CALL(dt, , 4)
120BOOST_REMOTE_CALL(dt, , 5)
121BOOST_REMOTE_CALL(dt, , 6)
122BOOST_REMOTE_CALL(dt, , 7)
123BOOST_REMOTE_CALL(dt, , 8)
124BOOST_REMOTE_CALL(dt, , 9)
125
126
127BOOST_REMOTE_CALL(st, pascal, 0)
128BOOST_REMOTE_CALL(st, pascal, 1)
129BOOST_REMOTE_CALL(st, pascal, 2)
130BOOST_REMOTE_CALL(st, pascal, 3)
131BOOST_REMOTE_CALL(st, pascal, 4)
132BOOST_REMOTE_CALL(st, pascal, 5)
133BOOST_REMOTE_CALL(st, pascal, 6)
134BOOST_REMOTE_CALL(st, pascal, 7)
135BOOST_REMOTE_CALL(st, pascal, 8)
136BOOST_REMOTE_CALL(st, pascal, 9)
137
138BOOST_REMOTE_CALL(dt, pascal, 0)
139BOOST_REMOTE_CALL(dt, pascal, 1)
140BOOST_REMOTE_CALL(dt, pascal, 2)
141BOOST_REMOTE_CALL(dt, pascal, 3)
142BOOST_REMOTE_CALL(dt, pascal, 4)
143BOOST_REMOTE_CALL(dt, pascal, 5)
144BOOST_REMOTE_CALL(dt, pascal, 6)
145BOOST_REMOTE_CALL(dt, pascal, 7)
146BOOST_REMOTE_CALL(dt, pascal, 8)
147BOOST_REMOTE_CALL(dt, pascal, 9)
148
149
150} // namespace mac
151
152} // namespace threads
153
154} // namespace boost
155
156
157#endif // BOOST_REMOTE_CALLS_MJM012402_HPP
Note: See TracBrowser for help on using the repository browser.