~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to extra/kipi-plugins/dlnaexport/extra/hupnp/src/utils/hthreadpool_p.h

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2010, 2011 Tuomo Penttinen, all rights reserved.
 
3
 *
 
4
 *  Author: Tuomo Penttinen <tp@herqq.org>
 
5
 *
 
6
 *  This file is part of Herqq UPnP (HUPnP) library.
 
7
 *
 
8
 *  Herqq UPnP is free software: you can redistribute it and/or modify
 
9
 *  it under the terms of the GNU Lesser General Public License as published by
 
10
 *  the Free Software Foundation, either version 3 of the License, or
 
11
 *  (at your option) any later version.
 
12
 *
 
13
 *  Herqq UPnP is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
16
 *  GNU Lesser General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU Lesser General Public License
 
19
 *  along with Herqq UPnP. If not, see <http://www.gnu.org/licenses/>.
 
20
 */
 
21
 
 
22
#ifndef HTHREADPOOL_P_H_
 
23
#define HTHREADPOOL_P_H_
 
24
 
 
25
//
 
26
// !! Warning !!
 
27
//
 
28
// This file is not part of public API and it should
 
29
// never be included in client code. The contents of this file may
 
30
// change or the file may be removed without of notice.
 
31
//
 
32
 
 
33
#include "../general/hupnp_defs.h"
 
34
 
 
35
#include <QtCore/QList>
 
36
#include <QtCore/QMutex>
 
37
#include <QtCore/QObject>
 
38
#include <QtCore/QAtomicInt>
 
39
#include <QtCore/QThreadPool>
 
40
#include <QtCore/QWaitCondition>
 
41
 
 
42
namespace Herqq
 
43
{
 
44
 
 
45
namespace Upnp
 
46
{
 
47
 
 
48
class HThreadPool;
 
49
 
 
50
//
 
51
//
 
52
//
 
53
class HRunnable :
 
54
    public QRunnable,
 
55
    public QObject
 
56
{
 
57
H_DISABLE_COPY(HRunnable)
 
58
friend class HThreadPool;
 
59
 
 
60
public:
 
61
 
 
62
    enum Status
 
63
    {
 
64
        NotStarted,
 
65
        WaitingNewTask,
 
66
        RunningTask,
 
67
        Exiting
 
68
    };
 
69
 
 
70
private:
 
71
 
 
72
    Status m_status;
 
73
    QMutex m_statusMutex;
 
74
    QWaitCondition m_statusWait;
 
75
 
 
76
    HThreadPool* m_owner;
 
77
    bool m_doNotInform;
 
78
 
 
79
public:
 
80
 
 
81
    HRunnable();
 
82
    virtual ~HRunnable() = 0;
 
83
 
 
84
    void signalTaskComplete();
 
85
    void signalExit();
 
86
 
 
87
    Status wait();
 
88
 
 
89
    bool setupNewTask();
 
90
};
 
91
 
 
92
//
 
93
//
 
94
//
 
95
class HThreadPool :
 
96
    public QObject
 
97
{
 
98
Q_OBJECT
 
99
H_DISABLE_COPY(HThreadPool)
 
100
friend class HRunnable;
 
101
 
 
102
private:
 
103
 
 
104
    QThreadPool* m_threadPool;
 
105
    QList<HRunnable*> m_runnables;
 
106
    QMutex m_runnablesMutex;
 
107
 
 
108
    void exiting(HRunnable*);
 
109
 
 
110
public:
 
111
 
 
112
    HThreadPool(QObject* parent);
 
113
    virtual ~HThreadPool();
 
114
 
 
115
    void start(HRunnable*);
 
116
    void shutdown();
 
117
 
 
118
    inline void setMaxThreadCount(qint32 count)
 
119
    {
 
120
        m_threadPool->setMaxThreadCount(count);
 
121
    }
 
122
 
 
123
    inline int activeThreadCount() const
 
124
    {
 
125
        return m_threadPool->activeThreadCount();
 
126
    }
 
127
};
 
128
 
 
129
}
 
130
}
 
131
 
 
132
#endif /* HTHREADPOOL_P_H_ */