annotate DEPENDENCIES/generic/include/boost/graph/parallel/simple_trigger.hpp @ 16:2665513ce2d3

Add boost headers
author Chris Cannam
date Tue, 05 Aug 2014 11:11:38 +0100
parents
children c530137014c0
rev   line source
Chris@16 1 // Copyright (C) 2007 Douglas Gregor
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 // This file contains a simplification of the "trigger" method for
Chris@16 8 // process groups. The simple trigger handles the common case where
Chris@16 9 // the handler associated with a trigger is a member function bound to
Chris@16 10 // a particular pointer.
Chris@16 11
Chris@16 12 #ifndef BOOST_GRAPH_PARALLEL_SIMPLE_TRIGGER_HPP
Chris@16 13 #define BOOST_GRAPH_PARALLEL_SIMPLE_TRIGGER_HPP
Chris@16 14
Chris@16 15 #ifndef BOOST_GRAPH_USE_MPI
Chris@16 16 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
Chris@16 17 #endif
Chris@16 18
Chris@16 19 #include <boost/graph/parallel/process_group.hpp>
Chris@16 20
Chris@16 21 namespace boost { namespace graph { namespace parallel {
Chris@16 22
Chris@16 23 namespace detail {
Chris@16 24
Chris@16 25 /**
Chris@16 26 * INTERNAL ONLY
Chris@16 27 *
Chris@16 28 * The actual function object that bridges from the normal trigger
Chris@16 29 * interface to the simplified interface. This is the equivalent of
Chris@16 30 * bind(pmf, self, _1, _2, _3, _4), but without the compile-time
Chris@16 31 * overhead of bind.
Chris@16 32 */
Chris@16 33 template<typename Class, typename T, typename Result>
Chris@16 34 class simple_trigger_t
Chris@16 35 {
Chris@16 36 public:
Chris@16 37 simple_trigger_t(Class* self,
Chris@16 38 Result (Class::*pmf)(int, int, const T&,
Chris@16 39 trigger_receive_context))
Chris@16 40 : self(self), pmf(pmf) { }
Chris@16 41
Chris@16 42 Result
Chris@16 43 operator()(int source, int tag, const T& data,
Chris@16 44 trigger_receive_context context) const
Chris@16 45 {
Chris@16 46 return (self->*pmf)(source, tag, data, context);
Chris@16 47 }
Chris@16 48
Chris@16 49 private:
Chris@16 50 Class* self;
Chris@16 51 Result (Class::*pmf)(int, int, const T&, trigger_receive_context);
Chris@16 52 };
Chris@16 53
Chris@16 54 } // end namespace detail
Chris@16 55
Chris@16 56 /**
Chris@16 57 * Simplified trigger interface that reduces the amount of code
Chris@16 58 * required to connect a process group trigger to a handler that is
Chris@16 59 * just a bound member function.
Chris@16 60 *
Chris@16 61 * INTERNAL ONLY
Chris@16 62 */
Chris@16 63 template<typename ProcessGroup, typename Class, typename T>
Chris@16 64 inline void
Chris@16 65 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@16 66 void (Class::*pmf)(int source, int tag, const T& data,
Chris@16 67 trigger_receive_context context), int)
Chris@16 68 {
Chris@16 69 pg.template trigger<T>(tag,
Chris@16 70 detail::simple_trigger_t<Class, T, void>(self, pmf));
Chris@16 71 }
Chris@16 72
Chris@16 73 /**
Chris@16 74 * Simplified trigger interface that reduces the amount of code
Chris@16 75 * required to connect a process group trigger with a reply to a
Chris@16 76 * handler that is just a bound member function.
Chris@16 77 *
Chris@16 78 * INTERNAL ONLY
Chris@16 79 */
Chris@16 80 template<typename ProcessGroup, typename Class, typename T, typename Result>
Chris@16 81 inline void
Chris@16 82 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@16 83 Result (Class::*pmf)(int source, int tag, const T& data,
Chris@16 84 trigger_receive_context context), long)
Chris@16 85 {
Chris@16 86 pg.template trigger_with_reply<T>
Chris@16 87 (tag, detail::simple_trigger_t<Class, T, Result>(self, pmf));
Chris@16 88 }
Chris@16 89
Chris@16 90 /**
Chris@16 91 * Simplified trigger interface that reduces the amount of code
Chris@16 92 * required to connect a process group trigger to a handler that is
Chris@16 93 * just a bound member function.
Chris@16 94 */
Chris@16 95 template<typename ProcessGroup, typename Class, typename T, typename Result>
Chris@16 96 inline void
Chris@16 97 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@16 98 Result (Class::*pmf)(int source, int tag, const T& data,
Chris@16 99 trigger_receive_context context))
Chris@16 100 {
Chris@16 101 // We pass 0 (an int) to help VC++ disambiguate calls to simple_trigger
Chris@16 102 // with Result=void.
Chris@16 103 simple_trigger(pg, tag, self, pmf, 0);
Chris@16 104 }
Chris@16 105
Chris@16 106 } } } // end namespace boost::graph::parallel
Chris@16 107
Chris@16 108 #endif // BOOST_GRAPH_PARALLEL_SIMPLE_TRIGGER_HPP