fix doc example typo
[boost.git] / boost / mpi / detail / communicator_sc.hpp
blob1dfcc3c52de95732acb9fffd77d3176ad3744996
1 // Copyright (C) 2006 Douglas Gregor <doug.gregor -at- gmail.com>.
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)
7 // Skeleton and content support for communicators
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
14 namespace boost { namespace mpi {
16 template<typename T>
17 void
18 communicator::send(int dest, int tag, const skeleton_proxy<T>& proxy) const
20 packed_skeleton_oarchive ar(*this);
21 ar << proxy.object;
22 send(dest, tag, ar);
25 template<typename T>
26 status
27 communicator::recv(int source, int tag, const skeleton_proxy<T>& proxy) const
29 packed_skeleton_iarchive ar(*this);
30 status result = recv(source, tag, ar);
31 ar >> proxy.object;
32 return result;
35 template<typename T>
36 status communicator::recv(int source, int tag, skeleton_proxy<T>& proxy) const
38 packed_skeleton_iarchive ar(*this);
39 status result = recv(source, tag, ar);
40 ar >> proxy.object;
41 return result;
44 template<typename T>
45 request
46 communicator::isend(int dest, int tag, const skeleton_proxy<T>& proxy) const
48 shared_ptr<packed_skeleton_oarchive>
49 archive(new packed_skeleton_oarchive(*this));
51 *archive << proxy.object;
52 request result = isend(dest, tag, *archive);
53 result.m_data = archive;
54 return result;
57 namespace detail {
58 template<typename T>
59 struct serialized_irecv_data<const skeleton_proxy<T> >
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) { }
66 void deserialize(status& stat)
68 isa >> proxy.object;
69 stat.m_count = 1;
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;
81 template<typename T>
82 struct serialized_irecv_data<skeleton_proxy<T> >
83 : public serialized_irecv_data<const skeleton_proxy<T> >
85 typedef serialized_irecv_data<const skeleton_proxy<T> > inherited;
87 serialized_irecv_data(const communicator& comm, int source, int tag,
88 const skeleton_proxy<T>& proxy)
89 : inherited(comm, source, tag, proxy) { }
93 } } // end namespace boost::mpi
95 #endif // BOOST_MPI_COMMUNICATOR_SC_HPP