Fledge
An open source edge computing platform for industrial users
connection_manager.h
1
#ifndef _CONNECTION_MANAGER_H
2
#define _CONNECTION_MANAGER_H
3
/*
4
* Fledge storage service.
5
*
6
* Copyright (c) 2017 OSisoft, LLC
7
*
8
* Released under the Apache 2.0 Licence
9
*
10
* Author: Mark Riddoch
11
*/
12
13
#include <plugin_api.h>
14
#include <list>
15
#include <mutex>
16
17
class
Connection
;
18
22
class
MemConnectionManager
{
23
public
:
24
static
MemConnectionManager
*getInstance();
25
void
growPool(
unsigned
int
);
26
unsigned
int
shrinkPool(
unsigned
int
);
27
Connection
*allocate();
28
void
release(
Connection
*);
29
void
shutdown();
30
void
setError(
const
char
*,
const
char
*,
bool
);
31
PLUGIN_ERROR
*getError()
32
{
33
return
&lastError;
34
}
35
void
setPersist(
bool
persist,
const
std::string& filename =
""
)
36
{
37
m_persist = persist;
38
m_filename = filename;
39
}
40
bool
persist() {
return
m_persist; };
41
std::string filename() {
return
m_filename; };
42
void
setPurgeBlockSize(
unsigned
long
purgeBlockSize);
43
44
private
:
45
MemConnectionManager
();
46
static
MemConnectionManager
*instance;
47
std::list<Connection *> idle;
48
std::list<Connection *> inUse;
49
std::mutex idleLock;
50
std::mutex inUseLock;
51
std::mutex errorLock;
52
PLUGIN_ERROR
lastError;
53
bool
m_trace;
54
bool
m_persist;
55
std::string m_filename;
56
unsigned
long
m_purgeBlockSize;
57
};
58
59
#endif
PLUGIN_ERROR
Structure used by plugins to return error information.
Definition:
plugin_api.h:44
Connection
Definition:
connection.h:32
MemConnectionManager
Singleton class to manage SQLite3 Memory connection pool.
Definition:
connection_manager.h:22
C
plugins
storage
sqlitememory
include
connection_manager.h
Generated by
1.8.17