本文整理汇总了C++中DatabaseConnection::start方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseConnection::start方法的具体用法?C++ DatabaseConnection::start怎么用?C++ DatabaseConnection::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseConnection
的用法示例。
在下文中一共展示了DatabaseConnection::start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: connections
//.........这里部分代码省略.........
// Disconnect the execution signal so if the old
// receiver is still around it won't keep getting
// signals
connection->disconnectQueue(
DatabaseConnection::EXECUTED);
// Rollback transaction if applicable
connection->call(Variant(),
QueryEvent::CLEAN_STATE);
}
} else if (currentRecord.expiry != 0
&& currentRecord.expiry > std::time(nullptr)) {
// This connection has expired
// Lock this connection's mutex
currentConnection->mutex.lock();
// Check if this connection is in the process of shutting
// down or is busy with something
busy = currentConnection->busy
|| !currentConnection->commands.empty();
// Unlock the mutex
currentConnection->mutex.unlock();
if (!busy) {
// Tell the connection to disconnect. We'll free memory
// after that is finished
if (!currentConnection->isStopping()) {
// Ensure this connection's signals are disconnected
currentConnection->disconnectQueue(
DatabaseConnection::EXECUTED);
// Connect to ourself. After the disconnect
// completes, we need to free the connection
currentConnection->connectQueue(
DatabaseConnection::EXECUTED, this);
currentConnection->call(Variant(currentRecord.uuid),
QueryEvent::DISCONNECT);
}
// Remove from the hash
this->connections.erase(currentConnection);
// Add to the disconnections hash
disconnectingConnections[currentRecord.uuid]
= currentConnection;
}
}
count++;
}
}
if (connection == nullptr && count < maxConnections) {
// Initialize new connection
connection = mainConnection->clone(this);
// Start new thread
connection->start();
}
if (connection != nullptr) {
record.expiry = timeout;
record.uuid = UUID::makeUUID();
record.receiver = receiver;
this->connections[connection] = record;
}
if (connection == nullptr) {
// Process any pending events
Application::getInstance()->processEvents();
// Also sleep for 30ms. There may not be events to process above
// and we don't want to pin the cpu
usleep(30 * 1000);
}
}
if (receiver != nullptr) {
// Lock mutex
connection->mutex.lock();
// Connect signal
connection->connectQueue(DatabaseConnection::EXECUTED, receiver);
// Unlock mutex
connection->mutex.unlock();
}
return connection;
}