Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:50:16

0001 // Copyright (C) 2007 Douglas Gregor 
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 // This file contains a simplification of the "trigger" method for
0008 // process groups. The simple trigger handles the common case where
0009 // the handler associated with a trigger is a member function bound to
0010 // a particular pointer.
0011 
0012 #ifndef BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP
0013 #define BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP
0014 
0015 #include <boost/property_map/parallel/process_group.hpp>
0016 
0017 namespace boost { namespace parallel {
0018 
0019 namespace detail {
0020 
0021 /**
0022  * INTERNAL ONLY
0023  *
0024  * The actual function object that bridges from the normal trigger
0025  * interface to the simplified interface. This is the equivalent of
0026  * bind(pmf, self, _1, _2, _3, _4), but without the compile-time
0027  * overhead of bind.
0028  */
0029 template<typename Class, typename T, typename Result>
0030 class simple_trigger_t 
0031 {
0032 public:
0033   simple_trigger_t(Class* self, 
0034                    Result (Class::*pmf)(int, int, const T&, 
0035                                         trigger_receive_context))
0036     : self(self), pmf(pmf) { }
0037 
0038   Result 
0039   operator()(int source, int tag, const T& data, 
0040              trigger_receive_context context) const
0041   {
0042     return (self->*pmf)(source, tag, data, context);
0043   }
0044 
0045 private:
0046   Class* self;
0047   Result (Class::*pmf)(int, int, const T&, trigger_receive_context);
0048 };
0049 
0050 } // end namespace detail
0051 
0052 /**
0053  * Simplified trigger interface that reduces the amount of code
0054  * required to connect a process group trigger to a handler that is
0055  * just a bound member function.
0056  *
0057  * INTERNAL ONLY
0058  */
0059 template<typename ProcessGroup, typename Class, typename T>
0060 inline void 
0061 simple_trigger(ProcessGroup& pg, int tag, Class* self, 
0062                void (Class::*pmf)(int source, int tag, const T& data, 
0063                                   trigger_receive_context context), int)
0064 {
0065   pg.template trigger<T>(tag, 
0066                          detail::simple_trigger_t<Class, T, void>(self, pmf));
0067 }
0068 
0069 /**
0070  * Simplified trigger interface that reduces the amount of code
0071  * required to connect a process group trigger with a reply to a
0072  * handler that is just a bound member function.
0073  *
0074  * INTERNAL ONLY
0075  */
0076 template<typename ProcessGroup, typename Class, typename T, typename Result>
0077 inline void 
0078 simple_trigger(ProcessGroup& pg, int tag, Class* self, 
0079                Result (Class::*pmf)(int source, int tag, const T& data, 
0080                                     trigger_receive_context context), long)
0081 {
0082   pg.template trigger_with_reply<T>
0083     (tag, detail::simple_trigger_t<Class, T, Result>(self, pmf));
0084 }
0085 
0086 /**
0087  * Simplified trigger interface that reduces the amount of code
0088  * required to connect a process group trigger to a handler that is
0089  * just a bound member function.
0090  */
0091 template<typename ProcessGroup, typename Class, typename T, typename Result>
0092 inline void 
0093 simple_trigger(ProcessGroup& pg, int tag, Class* self, 
0094                Result (Class::*pmf)(int source, int tag, const T& data, 
0095                                     trigger_receive_context context))
0096 {
0097         // We pass 0 (an int) to help VC++ disambiguate calls to simple_trigger 
0098         // with Result=void.
0099         simple_trigger(pg, tag, self, pmf, 0); 
0100 }
0101 
0102 } } // end namespace boost::parallel
0103 
0104 namespace boost { namespace graph { namespace parallel { using boost::parallel::simple_trigger; } } }
0105 
0106 #endif // BOOST_PROPERTY_MAP_PARALLEL_SIMPLE_TRIGGER_HPP