本文整理汇总了C++中QAtomicInt::store方法的典型用法代码示例。如果您正苦于以下问题:C++ QAtomicInt::store方法的具体用法?C++ QAtomicInt::store怎么用?C++ QAtomicInt::store使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAtomicInt
的用法示例。
在下文中一共展示了QAtomicInt::store方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recursive
void tst_QtConcurrentRun::recursive()
{
int levels = 15;
for (int i = 0; i < QThread::idealThreadCount(); ++i) {
count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveRun(levels);
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
}
for (int i = 0; i < QThread::idealThreadCount(); ++i) {
count.store(0);
QThreadPool::globalInstance()->setMaxThreadCount(i);
recursiveResult(levels);
QCOMPARE(count.load(), (int)pow(2.0, levels) - 1);
}
}
示例2: stresstest
void tst_QtConcurrentIterateKernel::stresstest()
{
const int iterations = 1000;
const int times = 50;
for (int i = 0; i < times; ++i) {
counter.store(0);
CountFor f(0, iterations);
f.startBlocking();
QCOMPARE(counter.load(), iterations);
}
}
示例3: ioTransferThread
static void CALLBACK ioTransferThread(UINT /*uTimerID*/, UINT /*uMsg*/, DWORD_PTR /*dwUser*/, DWORD_PTR /*dw1*/,
DWORD_PTR /*dw2*/)
{
iomap[0]++;
auto wkc1 = ec_send_processdata();
//auto wkc2 = ec_receive_processdata(EC_TIMEOUTRET);
auto wkc2 = ec_receive_processdata(EC_TIMEOUTSAFE);
if (wkc1 <= 0 || wkc2 <= 0)
globalErrorFlag.store(GLOBAL_ERROR);
}
示例4: throttling
void tst_QtConcurrentIterateKernel::throttling()
{
const int totalIterations = 400;
iterations.store(0);
threads.clear();
ThrottleFor f(0, totalIterations);
f.startBlocking();
QCOMPARE(iterations.load(), totalIterations);
QCOMPARE(threads.count(), 1);
}
示例5: PrintFor
PrintFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); }
示例6: ThrottleFor
// this class throttles between iterations 100 and 200,
// and then records how many threads that run between
// iterations 140 and 160.
ThrottleFor(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { iterations.store(0); throttling = false; }
示例7: requestInterruption
~Thread() override {
inDestructor.store(1);
requestInterruption();
quit();
wait();
}
示例8: open
bool Drive::open(const QString& adapterName)
{
qDebug() << "drive: open " << adapterName;
bool ok = true;
if (isOpened) {
assert(false && "repeated call is not supported");
ok = false;
}
if (ok) {
strcpy_s(adapterNameBuffer, adapterName.toStdString().c_str()); // TODO уязвимость
// initialise SOEM, bind socket to adapterNameBuffer
if (ec_init(adapterNameBuffer) <= 0) {
qDebug() << "ошибка ec_init";
ok = false;
}
}
// find and auto-config slaves
if (ok) {
isOpened = true; // TODO правильное ли место?
const auto slaveCount = ec_config_init(0);
if (slaveCount != 1) {
qDebug() << "количество найденных устройств равно " << slaveCount;
if (slaveCount == EC_OTHERFRAME)
qDebug() << "Ошибка: unknown frame received";
else if (slaveCount == EC_NOFRAME)
qDebug() << "Ошибка: no frame returned";
ok = false;
}
}
if (ok) {
// проверка, что подключен именно наш мотор
auto slave = &ec_slave[1];
if (slave->eep_man != 599 || slave->eep_id != 41220) {
qDebug() << "eep_man: " << slave->eep_man << ", slave->eep_id: " << slave->eep_id;
ok = false;
}
ec_slave[1].PO2SOconfig = &myPdoSetup;
}
if (ok) {
// Map all PDOs from slaves to iomap
ec_config_map(&iomap);
// wait for all slaves to reach SAFE_OP state
ec_statecheck(0, EC_STATE_SAFE_OP, EC_TIMEOUTSTATE * 4);
ec_slave[0].state = EC_STATE_OPERATIONAL; // TODO правильно ли, что это здесь?
// send one valid process data to make outputs in slaves happy
ec_send_processdata();
ec_receive_processdata(EC_TIMEOUTRET);
// start I/O transfer thread as periodic multimedia timer
globalErrorFlag.store(GLOBAL_OK);
timerEventId = timeSetEvent(1, 0, ioTransferThread, 0, TIME_PERIODIC); // TODO рассмотреть переход на CreateTimerQueueTimer
if (timerEventId == NULL) {
qDebug() << "Не удалось создать поток ввода/вывода";
ok = false;
}
}
if (ok) {
// request OP state for all slaves
ec_writestate(0);
// wait for all slaves to reach OP state
int chk = 40;
do
ec_statecheck(0, EC_STATE_OPERATIONAL, 50000);
while (chk-- && (ec_slave[0].state != EC_STATE_OPERATIONAL));
if (ec_slave[0].state != EC_STATE_OPERATIONAL) {// не удадось перевести метор в состояние OPERATIONAL
qDebug() << "не удадось перевести мотор в состояние OPERATIONAL";
ok = false;
}
while(EcatError)
qDebug("%s", ec_elist2string());
}
if (ok) {
int result = ec_SDOwrite(1, 0x4003, 0x01, FALSE, sizeof(deviceMode), &deviceMode, EC_TIMEOUTRXM); // Device Mode
if (result != 1)
qDebug() << "ошибка ec_SDOwrite: " << result;
while(EcatError)
qDebug("%s", ec_elist2string());
ok = (result == 1);
}
if (ok) {
timer.start(updatePeriod);
setPower(true);
}
else
close();
return ok;
}