本文整理汇总了C++中EventQueue::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ EventQueue::isEmpty方法的具体用法?C++ EventQueue::isEmpty怎么用?C++ EventQueue::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventQueue
的用法示例。
在下文中一共展示了EventQueue::isEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: post
void QWaitConditionPrivate::post(QWaitConditionEvent *wce, bool ret)
{
mtx.lock();
// remove 'wce' from the queue
queue.removeAll(wce);
ResetEvent(wce->event);
freeQueue.append(wce);
// wakeups delivered after the timeout should be forwarded to the next waiter
if (!ret && wce->wokenUp && !queue.isEmpty()) {
QWaitConditionEvent *other = queue.first();
SetEvent(other->event);
other->wokenUp = true;
}
mtx.unlock();
}
示例2: GetThreadPriority
QWaitConditionEvent *QWaitConditionPrivate::pre()
{
mtx.lock();
QWaitConditionEvent *wce =
freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
wce->priority = GetThreadPriority(GetCurrentThread());
wce->wokenUp = false;
// insert 'wce' into the queue (sorted by priority)
int index = 0;
for (; index < queue.size(); ++index) {
QWaitConditionEvent *current = queue.at(index);
if (current->priority < wce->priority)
break;
}
queue.insert(index, wce);
mtx.unlock();
return wce;
}
示例3: main
//.........这里部分代码省略.........
if (block && collision(ball, *block)) {
deflectBall(ball, *block);
block.reset();
}
}
//check if the ball collides with the paddle
if (collision(ball, paddle)) {
textLog << "collision between ball and paddle\n";
if (ball.getRect().getCenterX() < paddle.getRect().getCenterX()) {
ball.velocity.setX(-1);
}
else {
ball.velocity.setX(1);
}
ball.velocity.setY(-1);
}
};
//the function to use for drawing the current frame
auto drawFrame = [&]() {
//draw black background
al_clear_to_color(Color(0));
//draw the blocks
for(auto &blockPtr : blocks) {
if (blockPtr) blockPtr->draw();
}
//draw the paddle and ball
paddle.draw();
ball.draw();
};
//test fclose issue.
{
File test("text.txt", "r");
test.close();
}
//event loop
timer.start();
bool loop = true;
bool redraw = false;
while (loop) {
//time for redraw
if (redraw && eventQueue.isEmpty()) {
redraw = false;
drawFrame();
al_flip_display();
}
//wait for event
Event event = eventQueue.waitForEvent();
//process event
switch (event.getType()) {
//key down
case ALLEGRO_EVENT_KEY_DOWN:
switch (event.getKeyboardKeycode()) {
//end the loop
case ALLEGRO_KEY_ESCAPE:
loop = false;
break;
}
break;
//mouse
case ALLEGRO_EVENT_MOUSE_AXES:
paddle.position.setX(std::max(0, std::min(event.getMouseX() - paddle.bitmap.getWidth()/2, display.getWidth() - paddle.bitmap.getWidth())));
if (ball.velocity == Point<int>(0, 0)) {
ball.position.setX(paddle.position.getX() + paddle.bitmap.getWidth()/2 - ball.bitmap.getWidth()/2);
}
break;
//button down
case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
if (ball.velocity == Point<int>(0, 0)) {
ball.velocity.set(1, -1);
}
break;
//timer
case ALLEGRO_EVENT_TIMER:
if (event.getTimer() == timer) {
redraw = true;
updateLogic();
}
break;
//display close
case ALLEGRO_EVENT_DISPLAY_CLOSE:
loop = false;
break;
}
}
return 0;
}