当前位置: 首页>>代码示例>>C++>>正文


C++ EventQueue::isEmpty方法代码示例

本文整理汇总了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();
}
开发者ID:66eli77,项目名称:RadChip,代码行数:18,代码来源:qwaitcondition_win.cpp

示例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;
}
开发者ID:66eli77,项目名称:RadChip,代码行数:20,代码来源:qwaitcondition_win.cpp

示例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;
}
开发者ID:SpaceManiac,项目名称:ALX,代码行数:101,代码来源:example.cpp


注:本文中的EventQueue::isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。