void ActiveDispatcherTest::testTryWait() { ActiveObject activeObj; ActiveResult<int> result = activeObj.testMethod(123); assert (!result.available()); assert (!result.tryWait(200)); activeObj.cont(); assert (result.tryWait(10000)); assert (result.available()); assert (result.data() == 123); assert (!result.failed()); }
void SessionImpl::open(const std::string& connect) { if (connect != connectionString()) { if (isConnected()) throw InvalidAccessException("Session already connected"); if (!connect.empty()) setConnectionString(connect); } poco_assert_dbg (!connectionString().empty()); try { ActiveConnector connector(connectionString(), &_pDB); ActiveResult<int> result = connector.connect(); if (!result.tryWait(getLoginTimeout() * 1000)) throw ConnectionFailedException("Timed out."); int rc = result.data(); if (rc != 0) { close(); Utility::throwException(rc); } } catch (SQLiteException& ex) { throw ConnectionFailedException(ex.displayText()); } _connected = true; }
void SessionImpl::open(const std::string& connect) { if (connect != connectionString()) { if (isConnected()) throw InvalidAccessException("Session already connected"); if (!connect.empty()) setConnectionString(connect); } poco_assert_dbg (!connectionString().empty()); try { ActiveConnector connector(connectionString(), &_pDB); ActiveResult<int> result = connector.connect(); if (!result.tryWait(getLoginTimeout() * 1000)) throw ConnectionFailedException("Timed out."); int rc = result.data(); if (rc != 0) { close(); Utility::throwException(rc); } } catch (SQLiteException& ex) { throw ConnectionFailedException(ex.displayText()); } if (SQLITE_OK != sqlite3_exec(_pDB, "attach database ':memory:' as sys;" "create table sys.dual (dummy);", 0, 0, 0)) { throw ExecutionException("Cannot create system database."); } _connected = true; }