pgLab/asyncdbconnection.cpp

61 lines
1.2 KiB
C++

#include "asyncdbconnection.h"
ASyncDBConnection::ASyncDBConnection()
{
}
void ASyncDBConnection::setupConnection(const std::string &connstring)
{}
void ASyncDBConnection::closeConnection()
{}
void ASyncDBConnection::setStateCallback(on_state_callback state_callback)
{}
void ASyncDBConnection::Thread::run()
{
while (!terminateRequested) {
// make or recover connection
if (makeConnection()) {
// send commands and receive results
communicate();
}
}
// close connection
}
bool ASyncDBConnection::Thread::makeConnection()
{
while (!terminateRequested) {
// start connecting
// poll till complete or failed (we can get an abort command)
// if connected return true
// else retry (unless we get a command to stop then return false)
}
return false;
}
void ASyncDBConnection::Thread::communicate()
{
while (!terminateRequested) {
// wait for something to do:
// - command to send to server
// - wait for results and (notifies can also come in)
// - pass each result on to the completion routine
// - notify comming in from the server
// - pass to notify callback
// - connection raises an error
// - return
// - stop signal
// - return
}
}