~ubuntu-branches/ubuntu/intrepid/gwenview/intrepid

« back to all changes in this revision

Viewing changes to tsthread/tswaitcondition.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christopher Martin
  • Date: 2005-04-06 11:33:06 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050406113306-7zovl7z0io5bacpd
Tags: 1.2.0-1
* New upstream release.
  + Fixes crashes when using "Back" to navigate. (Closes: #301811)
* Enable KIPI support.
* Add a doc-base file for the handbook.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 
 
3
 Copyright (C) 2004 Lubos Lunak        <l.lunak@kde.org>
 
4
 
 
5
Permission is hereby granted, free of charge, to any person obtaining a
 
6
copy of this software and associated documentation files (the "Software"),
 
7
to deal in the Software without restriction, including without limitation
 
8
the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
9
and/or sell copies of the Software, and to permit persons to whom the
 
10
Software is furnished to do so, subject to the following conditions:
 
11
 
 
12
The above copyright notice and this permission notice shall be included in
 
13
all copies or substantial portions of the Software.
 
14
 
 
15
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
16
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
17
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
18
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
19
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
20
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
21
DEALINGS IN THE SOFTWARE.
 
22
 
 
23
****************************************************************************/
 
24
 
 
25
#include "tswaitcondition.h"
 
26
 
 
27
#include "tsthread.h"
 
28
 
 
29
bool TSWaitCondition::wait( QMutex* m, unsigned long time )
 
30
    {
 
31
    return cond.wait( m, time ); // TODO?
 
32
    }
 
33
 
 
34
bool TSWaitCondition::cancellableWait( QMutex* m, unsigned long time )
 
35
    {
 
36
    mutex.lock();
 
37
    if( !TSThread::currentThread()->setCancelData( &mutex, &cond ))
 
38
        {
 
39
        mutex.unlock();
 
40
        return false;
 
41
        }
 
42
    m->unlock();
 
43
    bool ret = cond.wait( &mutex, time );
 
44
    TSThread::currentThread()->setCancelData( NULL, NULL );
 
45
    mutex.unlock();
 
46
    m->lock();
 
47
    return ret;
 
48
    }
 
49
 
 
50
void TSWaitCondition::wakeOne()
 
51
    {
 
52
    QMutexLocker locker( &mutex );
 
53
    cond.wakeOne();
 
54
    }
 
55
 
 
56
void TSWaitCondition::wakeAll()
 
57
    {
 
58
    QMutexLocker locker( &mutex );
 
59
    cond.wakeAll();
 
60
    }