mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
fix for Statement async execution and a diagnostics improvement in RecordSet
This commit is contained in:
@@ -50,15 +50,14 @@ namespace Data {
|
||||
|
||||
Statement::Statement(StatementImpl* pImpl):
|
||||
_ptr(pImpl),
|
||||
_isAsync(false),
|
||||
_asyncExec(_ptr, &StatementImpl::execute)
|
||||
_async(false)
|
||||
{
|
||||
poco_check_ptr (pImpl);
|
||||
}
|
||||
|
||||
|
||||
Statement::Statement(Session& session):
|
||||
_asyncExec(_ptr, &StatementImpl::execute)
|
||||
_async(false)
|
||||
{
|
||||
reset(session);
|
||||
}
|
||||
@@ -66,9 +65,9 @@ Statement::Statement(Session& session):
|
||||
|
||||
Statement::Statement(const Statement& stmt):
|
||||
_ptr(stmt._ptr),
|
||||
_isAsync(stmt._isAsync),
|
||||
_async(stmt._async),
|
||||
_pResult(stmt._pResult),
|
||||
_asyncExec(_ptr, &StatementImpl::execute)
|
||||
_pAsyncExec(stmt._pAsyncExec)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -89,12 +88,20 @@ Statement& Statement::operator = (const Statement& stmt)
|
||||
void Statement::swap(Statement& other)
|
||||
{
|
||||
std::swap(_ptr, other._ptr);
|
||||
std::swap(_isAsync, other._isAsync);
|
||||
std::swap(_asyncExec, other._asyncExec);
|
||||
std::swap(_async, other._async);
|
||||
std::swap(_pAsyncExec, other._pAsyncExec);
|
||||
std::swap(_pResult, other._pResult);
|
||||
}
|
||||
|
||||
|
||||
Statement& Statement::reset(Session& session)
|
||||
{
|
||||
Statement stmt(session.createStatementImpl());
|
||||
swap(stmt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Statement::ResultType Statement::execute()
|
||||
{
|
||||
Mutex::ScopedLock lock(_mutex);
|
||||
@@ -129,12 +136,23 @@ const Statement::Result& Statement::executeAsync()
|
||||
const Statement::Result& Statement::doAsyncExec()
|
||||
{
|
||||
if (done()) _ptr->reset();
|
||||
_pResult = new Result(_asyncExec());
|
||||
if (!_pAsyncExec)
|
||||
_pAsyncExec = new AsyncExecMethod(_ptr, &StatementImpl::execute);
|
||||
poco_check_ptr (_pAsyncExec);
|
||||
_pResult = new Result((*_pAsyncExec)());
|
||||
poco_check_ptr (_pResult);
|
||||
return *_pResult;
|
||||
}
|
||||
|
||||
|
||||
void Statement::setAsync(bool async)
|
||||
{
|
||||
_async = async;
|
||||
if (_async && !_pAsyncExec)
|
||||
_pAsyncExec = new AsyncExecMethod(_ptr, &StatementImpl::execute);
|
||||
}
|
||||
|
||||
|
||||
Statement::ResultType Statement::wait(long milliseconds)
|
||||
{
|
||||
if (!_pResult) return 0;
|
||||
@@ -151,14 +169,6 @@ Statement::ResultType Statement::wait(long milliseconds)
|
||||
}
|
||||
|
||||
|
||||
Statement& Statement::reset(Session& session)
|
||||
{
|
||||
Statement stmt(session.createStatementImpl());
|
||||
swap(stmt);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
const std::string& Statement::getStorage() const
|
||||
{
|
||||
switch (storage())
|
||||
|
||||
Reference in New Issue
Block a user