/
transport.h
53 lines (48 loc) · 2.07 KB
/
transport.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef _STREAMING_QUEUE_TRANSPORT_H_
#define _STREAMING_QUEUE_TRANSPORT_H_
#include "ray/common/id.h"
#include "ray/core_worker/core_worker.h"
#include "util/streaming_logging.h"
namespace ray {
namespace streaming {
/// Transport is the transfer endpoint to a specific actor, buffers can be sent to peer through
/// direct actor call.
class Transport {
public:
/// Construct a Transport object.
/// \param[in] core_worker CoreWorker C++ pointer of current actor, which we call direct actor call
/// interface with.
/// \param[in] peer_actor_id actor id of peer actor
Transport(CoreWorker* core_worker, const ActorID &peer_actor_id)
: core_worker_(core_worker),
peer_actor_id_(peer_actor_id) {
}
virtual ~Transport() = default;
/// Send buffer asynchronously, peer's `function` will be called.
/// \param[in] buffer buffer to be sent.
/// \param[in] function the function descriptor of peer's function.
virtual void Send(std::unique_ptr<LocalMemoryBuffer> buffer, RayFunction &function);
/// Send buffer synchronously, peer's `function` will be called, and return the peer function's
/// return value.
/// \param[in] buffer buffer to be sent.
/// \param[in] function the function descriptor of peer's function.
/// \param[in] timeout_ms max time to wait for result.
/// \return peer function's result.
virtual std::shared_ptr<LocalMemoryBuffer> SendForResult(
std::shared_ptr<LocalMemoryBuffer> buffer, RayFunction &function, int64_t timeout_ms);
/// Send buffer and get result with retry.
/// return value.
/// \param[in] buffer buffer to be sent.
/// \param[in] function the function descriptor of peer's function.
/// \param[in] max retry count
/// \param[in] timeout_ms max time to wait for result.
/// \return peer function's result.
std::shared_ptr<LocalMemoryBuffer> SendForResultWithRetry(
std::unique_ptr<LocalMemoryBuffer> buffer, RayFunction &function, int retry_cnt, int64_t timeout_ms);
private:
CoreWorker* core_worker_;
ActorID peer_actor_id_;
};
} // namespace streaming
} // namespace ray
#endif