]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/mpi/detail/communicator_sc.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / mpi / detail / communicator_sc.hpp
1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Skeleton and content support for communicators
8
9 // This header should be included only after both communicator.hpp and
10 // skeleton_and_content.hpp have been included.
11 #ifndef BOOST_MPI_COMMUNICATOR_SC_HPP
12 #define BOOST_MPI_COMMUNICATOR_SC_HPP
13
14 namespace boost { namespace mpi {
15
16 template<typename T>
17 void
18 communicator::send(int dest, int tag, const skeleton_proxy<T>& proxy) const
19 {
20 packed_skeleton_oarchive ar(*this);
21 ar << proxy.object;
22 send(dest, tag, ar);
23 }
24
25 template<typename T>
26 status
27 communicator::recv(int source, int tag, const skeleton_proxy<T>& proxy) const
28 {
29 packed_skeleton_iarchive ar(*this);
30 status result = recv(source, tag, ar);
31 ar >> proxy.object;
32 return result;
33 }
34
35 template<typename T>
36 status communicator::recv(int source, int tag, skeleton_proxy<T>& proxy) const
37 {
38 packed_skeleton_iarchive ar(*this);
39 status result = recv(source, tag, ar);
40 ar >> proxy.object;
41 return result;
42 }
43
44 template<typename T>
45 request
46 communicator::isend(int dest, int tag, const skeleton_proxy<T>& proxy) const
47 {
48 shared_ptr<packed_skeleton_oarchive>
49 archive(new packed_skeleton_oarchive(*this));
50
51 *archive << proxy.object;
52 request result = isend(dest, tag, *archive);
53 result.m_data = archive;
54 return result;
55 }
56
57 namespace detail {
58 template<typename T>
59 struct serialized_irecv_data<const skeleton_proxy<T> >
60 {
61 serialized_irecv_data(const communicator& comm, int source, int tag,
62 skeleton_proxy<T> proxy)
63 : comm(comm), source(source), tag(tag), isa(comm),
64 ia(isa.get_skeleton()), proxy(proxy) { }
65
66 void deserialize(status& stat)
67 {
68 isa >> proxy.object;
69 stat.m_count = 1;
70 }
71
72 communicator comm;
73 int source;
74 int tag;
75 std::size_t count;
76 packed_skeleton_iarchive isa;
77 packed_iarchive& ia;
78 skeleton_proxy<T> proxy;
79 };
80
81 template<typename T>
82 struct serialized_irecv_data<skeleton_proxy<T> >
83 : public serialized_irecv_data<const skeleton_proxy<T> >
84 {
85 typedef serialized_irecv_data<const skeleton_proxy<T> > inherited;
86
87 serialized_irecv_data(const communicator& comm, int source, int tag,
88 const skeleton_proxy<T>& proxy)
89 : inherited(comm, source, tag, proxy) { }
90 };
91 }
92
93 } } // end namespace boost::mpi
94
95 #endif // BOOST_MPI_COMMUNICATOR_SC_HPP
96