The previous async method's are being updated to the ASyncDBConnection class. Connecting is working.
This commit is contained in:
parent
2d420c0525
commit
fce51a7b7e
7 changed files with 363 additions and 215 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue