- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Search for |

# dispatch_priv.hpp

Go to the documentation of this file.

    00001 //  Copyright (c) 2005-2009 Hartmut Kaiser
    00002 //
    00003 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
    00004 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    00005
    00006 #ifndef SAGA_SAGA_DETAIL_DISPATCH_PRIV_HPP
    00007 #define SAGA_SAGA_DETAIL_DISPATCH_PRIV_HPP
    00008
    00009 #include <saga/saga/task.hpp>
    00010
    00012 namespace saga { namespace detail
    00013 {
    00015
    00017     //  Helper templates dispatching the call to the required implementation.
    00018     //  This avoids writing every function thrice.
    00019     template <typename Tag>
    00020     struct dispatch_priv;
    00021
    00022     template <>
    00023     struct dispatch_priv<saga::task_base::Sync>
    00024     {
    00025         template <typename F, typename This>
    00026         static saga::task call(This& this_)
    00027         {
    00028             return F::call(this_, true);
    00029         }
    00030
    00031         template <typename F, typename This, typename T1>
    00032         static saga::task call(This& this_, T1 const& t1)
    00033         {
    00034             return F::call(this_, t1, true);
    00035         }
    00036
    00037         template <typename F, typename This, typename T1, typename T2>
    00038         static saga::task call(This& this_, T1 const& t1, T2 const& t2)
    00039         {
    00040             return F::call(this_, t1, t2, true);
    00041         }
    00042     };
    00043
    00044     template <>
    00045     struct dispatch_priv<saga::task_base::ASync>
    00046     {
    00047         template <typename F, typename This>
    00048         static saga::task call(This& this_)
    00049         {
    00050             return saga::detail::run(F::call(this_, false));
    00051         }
    00052
    00053         template <typename F, typename This, typename T1>
    00054         static saga::task call(This& this_, T1 const& t1)
    00055         {
    00056             return saga::detail::run(F::call(this_, t1, false));
    00057         }
    00058
    00059         template <typename F, typename This, typename T1, typename T2>
    00060         static saga::task call(This& this_, T1 const& t1, T2 const& t2)
    00061         {
    00062             return saga::detail::run(F::call(this_, t1, t2, false));
    00063         }
    00064     };
    00065
    00066     template <>
    00067     struct dispatch_priv<saga::task_base::Task>
    00068     {
    00069         template <typename F, typename This>
    00070         static saga::task call(This& this_)
    00071         {
    00072             return F::call(this_, false);
    00073         }
    00074
    00075         template <typename F, typename This, typename T1>
    00076         static saga::task call(This& this_, T1 const& t1)
    00077         {
    00078             return F::call(this_, t1, false);
    00079         }
    00080
    00081         template <typename F, typename This, typename T1, typename T2>
    00082         static saga::task call(This& this_, T1 const& t1, T2 const& t2)
    00083         {
    00084             return F::call(this_, t1, t2, false);
    00085         }
    00086     };
    00088
    00090 }}
    00091
    00092 #endif