lintel 0.2.0
Loading...
Searching...
No Matches
Notify.h
Go to the documentation of this file.
1#ifndef LINTEL_POSTGRESQL_NOTIFY_H
2#define LINTEL_POSTGRESQL_NOTIFY_H
3
4#include <libpq-fe.h>
5
6#include <atomic>
7#include <chrono>
8#include <functional>
9#include <string>
10#include <thread>
11
12#include "Connection.h"
13
14namespace lintel {
15namespace postgresql {
22 class Notify
23 {
24 private:
25 static constexpr int32_t kTimeoutSeconds = 1;
26 std::atomic<bool> m_shutdown = false;
27 Connection &m_connection;
28 PGconn *m_conn = nullptr;
29 std::thread m_thread;
30
31 std::string m_tableName;
32 std::function<void()> m_callBack;
34 std::chrono::seconds m_timeout{ kTimeoutSeconds };
35
37 void run();
38
40 void listen();
41
42 public:
49 explicit Notify(Connection &connection, std::string tableName, std::function<void()> &callBack);
50
53 };
54}// namespace postgresql
55
56}// namespace lintel
57#endif// LINTEL_POSTGRESQL_NOTIFY_H
Definition Connection.h:31
Definition Notify.h:23
Notify(Connection &connection, std::string tableName, std::function< void()> &callBack)
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9