remote_procedure.hpp 2.57 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2 3 4 5
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */
Matthieu Dorier's avatar
Matthieu Dorier committed
6 7 8 9 10 11 12
#ifndef __THALLIUM_REMOTE_PROCEDURE_HPP
#define __THALLIUM_REMOTE_PROCEDURE_HPP

#include <margo.h>

namespace thallium {

13
class engine;
Matthieu Dorier's avatar
Matthieu Dorier committed
14
class endpoint;
15
class provider_handle;
Matthieu Dorier's avatar
Matthieu Dorier committed
16 17
class callable_remote_procedure;

Matthieu Dorier's avatar
Matthieu Dorier committed
18 19 20 21 22 23 24
/**
 * @brief remote_procedure objects are produced by
 * engine::define() when defining an RPC.
 * Using remote_procedure::on(endpoint) creates a
 * callable_remote_procedure that can be called with
 * some parameters to send an RPC.
 */
Matthieu Dorier's avatar
Matthieu Dorier committed
25 26
class remote_procedure {

Matthieu Dorier's avatar
Matthieu Dorier committed
27
    friend class engine;
Matthieu Dorier's avatar
Matthieu Dorier committed
28 29

private:
30
    engine*  m_engine;
Matthieu Dorier's avatar
Matthieu Dorier committed
31
    hg_id_t  m_id;
32
    bool     m_ignore_response;
Matthieu Dorier's avatar
Matthieu Dorier committed
33

Matthieu Dorier's avatar
Matthieu Dorier committed
34 35 36 37 38 39 40
    /**
     * @brief Constructor. Made private because remote_procedure
     * objects are created only by engine::define().
     *
     * @param e Engine object that created the remote_procedure.
     * @param id Mercury RPC id.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
41
    remote_procedure(engine& e, hg_id_t id); 
Matthieu Dorier's avatar
Matthieu Dorier committed
42 43 44

public:

Matthieu Dorier's avatar
Matthieu Dorier committed
45 46 47
    /**
     * @brief Copy-constructor is default.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
48
    remote_procedure(const remote_procedure& other)            = default;
Matthieu Dorier's avatar
Matthieu Dorier committed
49 50 51 52

    /**
     * @brief Move-constructor is default.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
53
    remote_procedure(remote_procedure&& other)                 = default;
Matthieu Dorier's avatar
Matthieu Dorier committed
54 55 56 57

    /**
     * @brief Copy-assignment operator is default.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
58
    remote_procedure& operator=(const remote_procedure& other) = default;
Matthieu Dorier's avatar
Matthieu Dorier committed
59 60 61 62

    /**
     * @brief Move-assignment operator is default.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
63
    remote_procedure& operator=(remote_procedure&& other)      = default;
Matthieu Dorier's avatar
Matthieu Dorier committed
64 65 66 67

    /**
     * @brief Destructor is default.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
68
    ~remote_procedure()                                        = default;
Matthieu Dorier's avatar
Matthieu Dorier committed
69

Matthieu Dorier's avatar
Matthieu Dorier committed
70 71 72 73 74 75 76 77
    /**
     * @brief Creates a callable_remote_procedure by associating the
     * remote_procedure with an endpoint.
     *
     * @param ep endpoint with which to associate the procedure.
     *
     * @return a callable_remote_procedure.
     */
Matthieu Dorier's avatar
Matthieu Dorier committed
78
    callable_remote_procedure on(const endpoint& ep) const;
79
    
80 81 82 83 84 85 86 87 88 89 90

    /**
     * @brief Creates a callable remote_procedure by associating the
     * remote_procedure with a particular provider_handle.
     *
     * @param ph provider_handle with which to associate the procedure.
     *
     * @return a callable_remote_procedure.
     */
    callable_remote_procedure on(const provider_handle& ph) const;

Matthieu Dorier's avatar
Matthieu Dorier committed
91 92 93 94 95
    /**
     * @brief Tell the remote_procedure that it should not expect responses.
     *
     * @return *this
     */
96 97 98 99 100 101
    remote_procedure& disable_response();

    [[deprecated("use disable_response() instead")]]
    inline remote_procedure& ignore_response() {
        return disable_response();
    }
Matthieu Dorier's avatar
Matthieu Dorier committed
102 103 104 105 106 107

};

}

#endif