本文整理汇总了C++中QAtomicInt::fetchAndAddAcquire方法的典型用法代码示例。如果您正苦于以下问题:C++ QAtomicInt::fetchAndAddAcquire方法的具体用法?C++ QAtomicInt::fetchAndAddAcquire怎么用?C++ QAtomicInt::fetchAndAddAcquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAtomicInt
的用法示例。
在下文中一共展示了QAtomicInt::fetchAndAddAcquire方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
ULONG CDeckLinkGLWidget::AddRef ()
{
int oldValue;
oldValue = refCount.fetchAndAddAcquire(1);
return (ULONG)(oldValue + 1);
}
示例2: ID_COUNTER
toConnectionSub *toQPSqlConnectionImpl::createConnection(void)
{
// TODO shouldn't be this method reenteant?
static QAtomicInt ID_COUNTER(0);
int ID = ID_COUNTER.fetchAndAddAcquire(1);
QString dbName = QString::number(ID);
QSqlDatabase db = QSqlDatabase::addDatabase(parentConnection().provider(), dbName);
db.setDatabaseName(parentConnection().database());
QString host = parentConnection().host();
int pos = host.indexOf(QString(":"));
if (pos < 0)
db.setHostName(host);
else
{
db.setHostName(host.mid(0, pos));
db.setPort(host.mid(pos + 1).toInt());
}
QString opt;
QSet<QString> options = parentConnection().options();
if (options.find("Compress") != options.end())
opt += ";CLIENT_COMPRESS";
if (options.find("Ignore Space") != options.end())
opt += ";CLIENT_IGNORE_SPACE";
if (options.find("No Schema") != options.end())
opt += ";CLIENT_NO_SCHEMA";
if (options.find("SSL") != options.end())
opt += ";CLIENT_SSL";
if (!opt.isEmpty())
db.setConnectOptions(opt.mid(1)); // Strip first ; character
db.open(parentConnection().user(), parentConnection().password());
if (!db.isOpen())
{
QString t = toQPSqlConnectionSub::ErrorString(db.lastError());
QSqlDatabase::removeDatabase(dbName);
throw t;
}
toQPSqlConnectionSub *ret = new toQPSqlConnectionSub(parentConnection(), db, dbName);
return ret;
}
示例3: ID_COUNTER
toConnectionSub *toQSqlConnectionImpl::createConnection(void)
{
static QAtomicInt ID_COUNTER(0);
int ID = ID_COUNTER.fetchAndAddAcquire(1);
QString dbName = QString::number(ID);
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", dbName);
db.setDatabaseName(parentConnection().database());
db.open(parentConnection().user(), parentConnection().password());
if (!db.isOpen())
{
QString t = toQSqlConnectionSub::ErrorString(db.lastError());
QSqlDatabase::removeDatabase(dbName);
throw t;
}
toQSqlConnectionSub *ret = new toQSqlConnectionSub(parentConnection(), db, dbName);
return ret;
}
示例4: AddObject
int HandleManager::AddObject(AbstractController *obj)
{
int id = handleNum.fetchAndAddAcquire(1);
handleMap[id] = obj;
return id;
}