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


C++ QSemaphore::acquire方法代码示例

本文整理汇总了C++中QSemaphore::acquire方法的典型用法代码示例。如果您正苦于以下问题:C++ QSemaphore::acquire方法的具体用法?C++ QSemaphore::acquire怎么用?C++ QSemaphore::acquire使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSemaphore的用法示例。


在下文中一共展示了QSemaphore::acquire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: zablokujSockety

void WatekStatusu::zablokujSockety()
{
    pisanieWTrakcie.acquire();
    czytanie.acquire();
    mutCzytelnik.acquire();
    if (++iloscCzytlenikow == 1)
      pisanie.acquire();
    mutCzytelnik.release();
    czytanie.release();
    pisanieWTrakcie.release();
}
开发者ID:kamprog,项目名称:Komunikator,代码行数:11,代码来源:watekstatusu.cpp

示例2: run

void Customer::run() {
    waitChair.acquire(); // wait for a chair
    barberReady->acquire(); // wait for a barber to be ready
    l2.lock();
    int bID = buffer[out];
    out = (out + 1) % numBarbers;
    l2.unlock();
    waitChair.release(); // get up from the chair
    barberChair.acquire(); // wait for an available barber chair
    customerReady[bID].release(); // signal that customer is ready
    concurPrint(ID, bID);
    barberDone[bID].acquire(); // wait for barber to finish haircut
    barberChair.release(); // get up from barber's chair
}
开发者ID:sarvex,项目名称:multicore,代码行数:14,代码来源:fairBarber.cpp

示例3: run

void Consumer::run()
{
    for (int i = 0; i < DataSize; ++i) {
        usedSpace.acquire();
        QCOMPARE(buffer[i % BufferSize], alphabet[i % AlphabetSize]);
        freeSpace.release();
    }
    for (int i = 0; i < DataSize; ++i) {
        if ((i % ConsumerChunkSize) == 0)
            usedSpace.acquire(ConsumerChunkSize);
        QCOMPARE(buffer[i % BufferSize], alphabet[i % AlphabetSize]);
        if ((i % ConsumerChunkSize) == (ConsumerChunkSize - 1))
            freeSpace.release(ConsumerChunkSize);
    }
}
开发者ID:Mr-Kumar-Abhishek,项目名称:qt,代码行数:15,代码来源:tst_qsemaphore.cpp

示例4: odblokujSockety

void WatekStatusu::odblokujSockety()
{
    mutCzytelnik.acquire();
    if (--iloscCzytlenikow == 0)
      pisanie.release();
    mutCzytelnik.release();
}
开发者ID:kamprog,项目名称:Komunikator,代码行数:7,代码来源:watekstatusu.cpp

示例5: sipNoMethod

static PyObject *meth_QSemaphore_acquire(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
    PyObject *sipParseErr = NULL;

    {
        int a0 = 1;
        QSemaphore *sipCpp;

        static const char *sipKwdList[] = {
            sipName_n,
        };

        if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "B|i", &sipSelf, sipType_QSemaphore, &sipCpp, &a0))
        {
            Py_BEGIN_ALLOW_THREADS
            sipCpp->acquire(a0);
            Py_END_ALLOW_THREADS

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QSemaphore, sipName_acquire, NULL);

    return NULL;
}
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:28,代码来源:sipQtCoreQSemaphore.cpp

示例6: skin_surface_free

static void skin_surface_free(SkinSurface *s)
{
    D("skin_surface_free %d", s->id);
    QSemaphore semaphore;
    s->window->releaseBitmap(s, &semaphore);
    semaphore.acquire();
    free(s);
}
开发者ID:Dorahe,项目名称:platform_external_qemu,代码行数:8,代码来源:surface-qt.cpp

示例7: run

            void run()
            {
                testsTurn.release();

                threadsTurn.acquire();
                QVERIFY(!recursiveMutex.tryLock());
                testsTurn.release();

                threadsTurn.acquire();
                QVERIFY(recursiveMutex.tryLock());
                QVERIFY(lockCount.testAndSetRelaxed(0, 1));
                QVERIFY(recursiveMutex.tryLock());
                QVERIFY(lockCount.testAndSetRelaxed(1, 2));
                QVERIFY(lockCount.testAndSetRelaxed(2, 1));
                recursiveMutex.unlock();
                QVERIFY(lockCount.testAndSetRelaxed(1, 0));
                recursiveMutex.unlock();
                testsTurn.release();

                threadsTurn.acquire();
                QTime timer;
                timer.start();
                QVERIFY(!recursiveMutex.tryLock(waitTime));
                QVERIFY(timer.elapsed() >= waitTime);
                QVERIFY(!recursiveMutex.tryLock(0));
                testsTurn.release();

                threadsTurn.acquire();
                timer.start();
                QVERIFY(recursiveMutex.tryLock(waitTime));
                QVERIFY(timer.elapsed() <= waitTime);
                QVERIFY(lockCount.testAndSetRelaxed(0, 1));
                QVERIFY(recursiveMutex.tryLock(waitTime));
                QVERIFY(lockCount.testAndSetRelaxed(1, 2));
                QVERIFY(lockCount.testAndSetRelaxed(2, 1));
                recursiveMutex.unlock();
                QVERIFY(lockCount.testAndSetRelaxed(1, 0));
                recursiveMutex.unlock();
                testsTurn.release();

                threadsTurn.acquire();
                QVERIFY(!recursiveMutex.tryLock(0));
                QVERIFY(!recursiveMutex.tryLock(0));
                testsTurn.release();

                threadsTurn.acquire();
                timer.start();
                QVERIFY(recursiveMutex.tryLock(0));
                QVERIFY(timer.elapsed() < waitTime);
                QVERIFY(lockCount.testAndSetRelaxed(0, 1));
                QVERIFY(recursiveMutex.tryLock(0));
                QVERIFY(lockCount.testAndSetRelaxed(1, 2));
                QVERIFY(lockCount.testAndSetRelaxed(2, 1));
                recursiveMutex.unlock();
                QVERIFY(lockCount.testAndSetRelaxed(1, 0));
                recursiveMutex.unlock();
                testsTurn.release();

                threadsTurn.acquire();
            }
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:60,代码来源:tst_qmutex.cpp

示例8: skin_surface_fill

extern void skin_surface_fill(SkinSurface *dst, SkinRect *rect, uint32_t argb_premul)
{
    D("skin_surface_fill %d: %d, %d, %d, %d: %x", dst->id, rect->pos.x, rect->pos.y, rect->size.w, rect->size.h, argb_premul);
    QRect qrect(rect->pos.x, rect->pos.y, rect->size.w, rect->size.h);
    QColor color(argb_premul);
    QSemaphore semaphore;
    dst->window->fill(dst, &qrect, &color, &semaphore);
    semaphore.acquire();
}
开发者ID:Dorahe,项目名称:platform_external_qemu,代码行数:9,代码来源:surface-qt.cpp

示例9: skin_event_poll

extern bool skin_event_poll(SkinEvent* event) {
    bool retval;
    QSemaphore semaphore;
    EmulatorWindow *window = EmulatorWindow::getInstance();
    if (window == false) return false;
    window->pollEvent(event, &retval, &semaphore);
    semaphore.acquire();
    return retval;
}
开发者ID:Dorahe,项目名称:platform_external_qemu,代码行数:9,代码来源:event-qt.cpp

示例10: skin_surface_update

extern void skin_surface_update(SkinSurface *surface, SkinRect *rect)
{
#if 0
    D("skin_surface_update %d: %d,%d,%d,%d", surface->id, rect->pos.x, rect->pos.y, rect->size.w, rect->size.h);
#endif
    QRect qrect(rect->pos.x, rect->pos.y, rect->size.w, rect->size.h);
    QSemaphore semaphore;
    surface->window->requestUpdate(&qrect, &semaphore);
    semaphore.acquire();
}
开发者ID:Dorahe,项目名称:platform_external_qemu,代码行数:10,代码来源:surface-qt.cpp

示例11: run

void Consumer::run()
{
    for (int i = 0; i < DataSize; ++i) {
        usedBytes.acquire();
        fprintf(stderr, "%c", buffer[i % BufferSize]);
        freeBytes.release();
    }

    fprintf(stderr, "\n");
}
开发者ID:yujiajia,项目名称:Just-Go,代码行数:10,代码来源:main.cpp

示例12: debug

/**
 * \brief Thread-safe vypis o behu servru.
 * \param msg Sprava pre vypis
 * \retval void
 */
void debug(const char * msg) {
    static QSemaphore my_sem(1);

    my_sem.acquire();

    qDebug() << "[" << QThread::currentThreadId() << "]"
             <<QTime::currentTime().toString() << msg;

    my_sem.release();
}
开发者ID:fridex,项目名称:petrinet-simulator,代码行数:15,代码来源:debug.cpp

示例13: run

            void run()
            {
                testsTurn.release();

                threadsTurn.acquire();
                QVERIFY(!readWriteLock.tryLockForRead());
                testsTurn.release();

                threadsTurn.acquire();
                QVERIFY(readWriteLock.tryLockForRead());
                lockCount.ref();
                QVERIFY(readWriteLock.tryLockForRead());
                lockCount.ref();
                lockCount.deref();
                readWriteLock.unlock();
                lockCount.deref();
                readWriteLock.unlock();
                testsTurn.release();

                threadsTurn.acquire();
                QTime timer;
                timer.start();
                QVERIFY(!readWriteLock.tryLockForRead(1000));
                QVERIFY(timer.elapsed() >= 1000);
                testsTurn.release();

                threadsTurn.acquire();
                timer.start();
                QVERIFY(readWriteLock.tryLockForRead(1000));
                QVERIFY(timer.elapsed() <= 1000);
                lockCount.ref();
                QVERIFY(readWriteLock.tryLockForRead(1000));
                lockCount.ref();
                lockCount.deref();
                readWriteLock.unlock();
                lockCount.deref();
                readWriteLock.unlock();
                testsTurn.release();

                threadsTurn.acquire();
            }
开发者ID:RS102839,项目名称:qt,代码行数:41,代码来源:tst_qreadwritelock.cpp

示例14: main

int main( int argc, char** argv ) {
   qRegisterMetaType<vector<string> >("vector<string>");

   QThread* thread = new MainProcessingThread( );
   thread->start();
  // thread->exec();
   QApplication* app = new QApplication( argc, argv );
   semaphore.acquire();
   grid = new GridViewer(districtMap);
   QObject::connect( thread, SIGNAL(sendPath(vector<string>)), grid, SLOT(sendPath(vector<string>))); //, Qt::QueuedConnection );
   grid->show();
   app->exec();
}
开发者ID:edemairy,项目名称:TC,代码行数:13,代码来源:main.cpp

示例15: skin_surface_create_window

extern SkinSurface* skin_surface_create_window(int x, int y, int w, int h, int original_w, int original_h, int is_fullscreen)
{
    D("skin_surface_create_window  %d, %d, %d, %d, %d, %d, fullscreen: %d", x, y, w, h, original_w, original_h, is_fullscreen);
    QSemaphore semaphore;
    EmulatorWindow *window = EmulatorWindow::getInstance();
    if (window == NULL) return NULL;
    SkinSurface *surface = create_surface(w, h, original_w, original_h);
    QRect rect(x, y, w, h);
    window->showWindow(surface, &rect, is_fullscreen, &semaphore);
    semaphore.acquire();
    D("ID of backing bitmap surface is %d", surface->id);
    return surface;
}
开发者ID:Dorahe,项目名称:platform_external_qemu,代码行数:13,代码来源:surface-qt.cpp


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