The previous async method's are being updated to the ASyncDBConnection class. Connecting is working.

This commit is contained in:
Eelke Klein 2017-01-06 07:23:40 +01:00
parent 2d420c0525
commit fce51a7b7e
7 changed files with 363 additions and 215 deletions

View file

@ -2,8 +2,11 @@
#define ASYNCDBCONNECTION_H
#include "PgsqlConn.h"
#include "win32event.h"
#include <functional>
#include <mutex>
#include <vector>
#include <thread>
class ASyncDBConnection {
public:
@ -45,24 +48,36 @@ private:
/// Contains all the members accessed by the thread
class Thread {
public:
on_state_callback m_state_callback;
std::string m_init_string;
on_state_callback m_stateCallback;
std::mutex m_stateCallbackMutex;
std::string m_initString;
Thread();
/// Is started as a seperate thread by ASyncDBConnection
void run();
/// Sends a cancel request to the DB server
void cancel();
void stop();
private:
Win32Event m_stopEvent;
Pgsql::Connection m_connection;
bool terminateRequested = false; ///< is set when the thread should stop
bool makeConnection();
void communicate();
void doStateCallback(State state);
};
Thread thread;
Thread m_threadData;
std::thread m_thread;
};
#endif // ASYNCDBCONNECTION_H