Chris@16
|
1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
|
Chris@16
|
2
|
Chris@16
|
3 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 /** @file request.hpp
|
Chris@16
|
8 *
|
Chris@16
|
9 * This header defines the class @c request, which contains a request
|
Chris@16
|
10 * for non-blocking communication.
|
Chris@16
|
11 */
|
Chris@16
|
12 #ifndef BOOST_MPI_REQUEST_HPP
|
Chris@16
|
13 #define BOOST_MPI_REQUEST_HPP
|
Chris@16
|
14
|
Chris@16
|
15 #include <boost/mpi/config.hpp>
|
Chris@16
|
16 #include <boost/optional.hpp>
|
Chris@16
|
17 #include <boost/shared_ptr.hpp>
|
Chris@16
|
18 #include <boost/mpi/packed_iarchive.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace mpi {
|
Chris@16
|
21
|
Chris@16
|
22 class status;
|
Chris@16
|
23 class communicator;
|
Chris@16
|
24
|
Chris@16
|
25 /**
|
Chris@16
|
26 * @brief A request for a non-blocking send or receive.
|
Chris@16
|
27 *
|
Chris@16
|
28 * This structure contains information about a non-blocking send or
|
Chris@16
|
29 * receive and will be returned from @c isend or @c irecv,
|
Chris@16
|
30 * respectively.
|
Chris@16
|
31 */
|
Chris@16
|
32 class BOOST_MPI_DECL request
|
Chris@16
|
33 {
|
Chris@16
|
34 public:
|
Chris@16
|
35 /**
|
Chris@16
|
36 * Constructs a NULL request.
|
Chris@16
|
37 */
|
Chris@16
|
38 request();
|
Chris@16
|
39
|
Chris@16
|
40 /**
|
Chris@16
|
41 * Wait until the communication associated with this request has
|
Chris@16
|
42 * completed, then return a @c status object describing the
|
Chris@16
|
43 * communication.
|
Chris@16
|
44 */
|
Chris@16
|
45 status wait();
|
Chris@16
|
46
|
Chris@16
|
47 /**
|
Chris@16
|
48 * Determine whether the communication associated with this request
|
Chris@16
|
49 * has completed successfully. If so, returns the @c status object
|
Chris@16
|
50 * describing the communication. Otherwise, returns an empty @c
|
Chris@16
|
51 * optional<> to indicate that the communication has not completed
|
Chris@16
|
52 * yet. Note that once @c test() returns a @c status object, the
|
Chris@16
|
53 * request has completed and @c wait() should not be called.
|
Chris@16
|
54 */
|
Chris@16
|
55 optional<status> test();
|
Chris@16
|
56
|
Chris@16
|
57 /**
|
Chris@16
|
58 * Cancel a pending communication, assuming it has not already been
|
Chris@16
|
59 * completed.
|
Chris@16
|
60 */
|
Chris@16
|
61 void cancel();
|
Chris@16
|
62
|
Chris@16
|
63 private:
|
Chris@16
|
64 enum request_action { ra_wait, ra_test, ra_cancel };
|
Chris@16
|
65 typedef optional<status> (*handler_type)(request* self,
|
Chris@16
|
66 request_action action);
|
Chris@16
|
67
|
Chris@16
|
68 /**
|
Chris@16
|
69 * INTERNAL ONLY
|
Chris@16
|
70 *
|
Chris@16
|
71 * Handles the non-blocking receive of a serialized value.
|
Chris@16
|
72 */
|
Chris@16
|
73 template<typename T>
|
Chris@16
|
74 static optional<status>
|
Chris@16
|
75 handle_serialized_irecv(request* self, request_action action);
|
Chris@16
|
76
|
Chris@16
|
77 /**
|
Chris@16
|
78 * INTERNAL ONLY
|
Chris@16
|
79 *
|
Chris@16
|
80 * Handles the non-blocking receive of an array of serialized values.
|
Chris@16
|
81 */
|
Chris@16
|
82 template<typename T>
|
Chris@16
|
83 static optional<status>
|
Chris@16
|
84 handle_serialized_array_irecv(request* self, request_action action);
|
Chris@16
|
85
|
Chris@16
|
86 public: // template friends are not portable
|
Chris@16
|
87
|
Chris@16
|
88 /// INTERNAL ONLY
|
Chris@16
|
89 MPI_Request m_requests[2];
|
Chris@16
|
90
|
Chris@16
|
91 /// INTERNAL ONLY
|
Chris@16
|
92 handler_type m_handler;
|
Chris@16
|
93
|
Chris@16
|
94 /// INTERNAL ONLY
|
Chris@16
|
95 shared_ptr<void> m_data;
|
Chris@16
|
96
|
Chris@16
|
97 friend class communicator;
|
Chris@16
|
98 };
|
Chris@16
|
99
|
Chris@16
|
100 } } // end namespace boost::mpi
|
Chris@16
|
101
|
Chris@16
|
102 #endif // BOOST_MPI_REQUEST_HPP
|