annotate DEPENDENCIES/generic/include/boost/property_map/parallel/simple_trigger.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Copyright (C) 2007 Douglas Gregor
Chris@102 2
Chris@102 3 // Use, modification and distribution is subject to the Boost Software
Chris@102 4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 5 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 6
Chris@102 7 // This file contains a simplification of the "trigger" method for
Chris@102 8 // process groups. The simple trigger handles the common case where
Chris@102 9 // the handler associated with a trigger is a member function bound to
Chris@102 10 // a particular pointer.
Chris@102 11
Chris@102 12 #ifndef BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP
Chris@102 13 #define BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP
Chris@102 14
Chris@102 15 #include <boost/property_map/parallel/process_group.hpp>
Chris@102 16
Chris@102 17 namespace boost { namespace parallel {
Chris@102 18
Chris@102 19 namespace detail {
Chris@102 20
Chris@102 21 /**
Chris@102 22 * INTERNAL ONLY
Chris@102 23 *
Chris@102 24 * The actual function object that bridges from the normal trigger
Chris@102 25 * interface to the simplified interface. This is the equivalent of
Chris@102 26 * bind(pmf, self, _1, _2, _3, _4), but without the compile-time
Chris@102 27 * overhead of bind.
Chris@102 28 */
Chris@102 29 template<typename Class, typename T, typename Result>
Chris@102 30 class simple_trigger_t
Chris@102 31 {
Chris@102 32 public:
Chris@102 33 simple_trigger_t(Class* self,
Chris@102 34 Result (Class::*pmf)(int, int, const T&,
Chris@102 35 trigger_receive_context))
Chris@102 36 : self(self), pmf(pmf) { }
Chris@102 37
Chris@102 38 Result
Chris@102 39 operator()(int source, int tag, const T& data,
Chris@102 40 trigger_receive_context context) const
Chris@102 41 {
Chris@102 42 return (self->*pmf)(source, tag, data, context);
Chris@102 43 }
Chris@102 44
Chris@102 45 private:
Chris@102 46 Class* self;
Chris@102 47 Result (Class::*pmf)(int, int, const T&, trigger_receive_context);
Chris@102 48 };
Chris@102 49
Chris@102 50 } // end namespace detail
Chris@102 51
Chris@102 52 /**
Chris@102 53 * Simplified trigger interface that reduces the amount of code
Chris@102 54 * required to connect a process group trigger to a handler that is
Chris@102 55 * just a bound member function.
Chris@102 56 *
Chris@102 57 * INTERNAL ONLY
Chris@102 58 */
Chris@102 59 template<typename ProcessGroup, typename Class, typename T>
Chris@102 60 inline void
Chris@102 61 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@102 62 void (Class::*pmf)(int source, int tag, const T& data,
Chris@102 63 trigger_receive_context context), int)
Chris@102 64 {
Chris@102 65 pg.template trigger<T>(tag,
Chris@102 66 detail::simple_trigger_t<Class, T, void>(self, pmf));
Chris@102 67 }
Chris@102 68
Chris@102 69 /**
Chris@102 70 * Simplified trigger interface that reduces the amount of code
Chris@102 71 * required to connect a process group trigger with a reply to a
Chris@102 72 * handler that is just a bound member function.
Chris@102 73 *
Chris@102 74 * INTERNAL ONLY
Chris@102 75 */
Chris@102 76 template<typename ProcessGroup, typename Class, typename T, typename Result>
Chris@102 77 inline void
Chris@102 78 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@102 79 Result (Class::*pmf)(int source, int tag, const T& data,
Chris@102 80 trigger_receive_context context), long)
Chris@102 81 {
Chris@102 82 pg.template trigger_with_reply<T>
Chris@102 83 (tag, detail::simple_trigger_t<Class, T, Result>(self, pmf));
Chris@102 84 }
Chris@102 85
Chris@102 86 /**
Chris@102 87 * Simplified trigger interface that reduces the amount of code
Chris@102 88 * required to connect a process group trigger to a handler that is
Chris@102 89 * just a bound member function.
Chris@102 90 */
Chris@102 91 template<typename ProcessGroup, typename Class, typename T, typename Result>
Chris@102 92 inline void
Chris@102 93 simple_trigger(ProcessGroup& pg, int tag, Class* self,
Chris@102 94 Result (Class::*pmf)(int source, int tag, const T& data,
Chris@102 95 trigger_receive_context context))
Chris@102 96 {
Chris@102 97 // We pass 0 (an int) to help VC++ disambiguate calls to simple_trigger
Chris@102 98 // with Result=void.
Chris@102 99 simple_trigger(pg, tag, self, pmf, 0);
Chris@102 100 }
Chris@102 101
Chris@102 102 } } // end namespace boost::parallel
Chris@102 103
Chris@102 104 namespace boost { namespace graph { namespace parallel { using boost::parallel::simple_trigger; } } }
Chris@102 105
Chris@102 106 #endif // BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP