blob: 92d8ac307961f389023097522a1426dedeae66ec (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <memory>
#include <vbench/core/socket.h>
#include "server_spec.h"
namespace vbench {
/**
* A connection to a specific server that can be reused at a later
* time to support persistent connections.
**/
class HttpConnection
{
private:
ServerSpec _server;
Socket _socket;
double _lastUsed;
public:
typedef std::unique_ptr<HttpConnection> UP;
HttpConnection(const ServerSpec &server);
bool fresh() const { return (_lastUsed < 0); }
const ServerSpec &server() const { return _server; }
Stream &stream() { return _socket; }
void touch(double now) { _lastUsed = now; }
bool mayReuse(double now) const;
};
} // namespace vbench
|