blob: d459cb9ee3e39a6423a6713be41bb51ce5bf023e (
plain) (
blame)
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
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <vespa/fnet/connection.h>
#include <vespa/vespalib/util/ref_counted.h>
#include <atomic>
class FNET_Scheduler;
class FRT_RPCRequest;
class FRT_IRequestWait;
class FRT_Target : public vespalib::enable_ref_counted
{
private:
FNET_Scheduler *_scheduler;
FNET_Connection *_conn;
FRT_Target(const FRT_Target &);
FRT_Target &operator=(const FRT_Target &);
public:
FRT_Target(FNET_Scheduler *scheduler, FNET_Connection *conn)
: _scheduler(scheduler),
_conn(conn) {}
~FRT_Target();
FNET_Connection *GetConnection() const { return _conn; }
bool IsValid() {
return ((_conn != nullptr) &&
(_conn->GetState() <= FNET_Connection::FNET_CONNECTED));
}
void InvokeAsync(FRT_RPCRequest *req, double timeout, FRT_IRequestWait *waiter);
void InvokeVoid(FRT_RPCRequest *req);
void InvokeSync(FRT_RPCRequest *req, double timeout);
};
|