blob: 3a2927c5878e7abfeb29353bd9786b76b42e4ac0 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "http_connection.h"
#include <vbench/core/timer.h>
#include <vespa/vespalib/util/arrayqueue.hpp>
#include <vespa/vespalib/util/sync.h>
#include <map>
namespace vbench {
/**
* A pool of http connections used to support persistent
* connections. The pool is shared between threads to reduce the
* number of needed connections when using many servers.
**/
class HttpConnectionPool
{
private:
typedef vespalib::ArrayQueue<HttpConnection::UP> Queue;
typedef std::map<ServerSpec, size_t> Map;
vespalib::Lock _lock;
Map _map;
std::vector<Queue> _store;
Timer &_timer;
public:
HttpConnectionPool(Timer &timer);
~HttpConnectionPool();
HttpConnection::UP getConnection(const ServerSpec &server);
void putConnection(HttpConnection::UP conn);
};
} // namespace vbench
|