Changeset 66 for trunk


Ignore:
Timestamp:
Jun 29, 2009, 11:49:20 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

corelib: OS/2: Ported QWaitCondition.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/thread/qwaitcondition_os2.cpp

    r63 r66  
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    44** Contact: Qt Software Information ([email protected])
     5
     6
    57**
    68** This file is part of the QtCore module of the Qt Toolkit.
     
    4648#include "qlist.h"
    4749#include "qalgorithms.h"
    48 #include "qt_windows.h"
     50#include "qt_.h"
    4951
    5052#ifndef QT_NO_THREAD
    5153
    52 #define Q_MUTEX_T void*
    5354#include <private/qmutex_p.h>
    5455#include <private/qreadwritelock_p.h>
     
    6566    inline QWaitConditionEvent() : priority(0), wokenUp(false)
    6667    {
    67         QT_WA ({
    68             event = CreateEvent(NULL, TRUE, FALSE, NULL);
    69         }, {
    70             event = CreateEventA(NULL, TRUE, FALSE, NULL);
    71         });
    72     }
    73     inline ~QWaitConditionEvent() { CloseHandle(event); }
     68        event = NULLHANDLE;
     69        DosCreateEventSem(NULL, &event, 0, FALSE);
     70    }
     71    inline ~QWaitConditionEvent() { DosCloseEventSem(event); }
    7472    int priority;
    7573    bool wokenUp;
    76     HANDLE event;
     74    H event;
    7775};
    7876
     
    9694    QWaitConditionEvent *wce =
    9795        freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.takeFirst();
    98     wce->priority = GetThreadPriority(GetCurrentThread());
     96
     97    PTIB ptib;
     98    DosGetInfoBlocks(&ptib, NULL);
     99    wce->priority = ptib->tib_ptib2->tib2_ulpri;
     100
    99101    wce->wokenUp = false;
    100102
     
    116118    // wait for the event
    117119    bool ret = false;
    118     switch (WaitForSingleObject(wce->event, time)) {
    119     default: break;
    120 
    121     case WAIT_OBJECT_0:
     120    APIRET rc = DosWaitEventSem(wce->event, time);
     121    if (rc == NO_ERROR)
    122122        ret = true;
    123         break;
    124     }
     123
    125124    return ret;
    126125}
     
    132131    // remove 'wce' from the queue
    133132    queue.removeAll(wce);
    134     ResetEvent(wce->event);
     133    ULONG posts;
     134    DosResetEventSem(wce->event, &posts);
    135135    freeQueue.append(wce);
    136136
     
    138138    if (!ret && wce->wokenUp && !queue.isEmpty()) {
    139139        QWaitConditionEvent *other = queue.first();
    140         SetEvent(other->event);
     140        (other->event);
    141141        other->wokenUp = true;
    142142    }
     
    217217        if (current->wokenUp)
    218218            continue;
    219         SetEvent(current->event);
     219        (current->event);
    220220        current->wokenUp = true;
    221221        break;
     
    229229    for (int i = 0; i < d->queue.size(); ++i) {
    230230        QWaitConditionEvent *current = d->queue.at(i);
    231         SetEvent(current->event);
     231        (current->event);
    232232        current->wokenUp = true;
    233233    }
     
    235235
    236236QT_END_NAMESPACE
     237
    237238#endif // QT_NO_THREAD
Note: See TracChangeset for help on using the changeset viewer.