summaryrefslogtreecommitdiffstats
path: root/src/dict/dict-connection.h
blob: 2241dade79f0779e863650730dab0252b8c3b448 (plain)
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
#ifndef DICT_CONNECTION_H
#define DICT_CONNECTION_H

#include "dict.h"
#include "connection.h"

struct dict_connection_transaction {
	unsigned int id;
	struct dict_connection *conn;
	struct dict_transaction_context *ctx;
};

struct dict_connection {
	struct connection conn;
	struct dict_connection *prev, *next;
	struct dict_server *server;
	int refcount;

	char *name;
	struct dict *dict;
	enum dict_data_type value_type;

	struct timeout *to_unref;

	/* There are only a few transactions per client, so keeping them in
	   array is fast enough */
	ARRAY(struct dict_connection_transaction) transactions;
	ARRAY(struct dict_connection_cmd *) cmds;
	unsigned int async_id_counter;

	bool iter_flush_pending;
	bool destroyed;
};

struct master_service_connection;

struct dict_connection *
dict_connection_create(struct master_service_connection *master_conn);

void dict_connection_ref(struct dict_connection *conn);
bool dict_connection_unref(struct dict_connection *conn);
void dict_connection_unref_safe(struct dict_connection *conn);

unsigned int dict_connections_current_count(void);
void dict_connections_init(void);
void dict_connections_destroy_all(void);

#endif