F:/KPlato/koffice/libs/kofficecore/threadAction/KoJobsListPolicy.cpp

Aller à la documentation de ce fichier.
00001 /*
00002  * Copyright (C) 2006 Thomas Zander <zander@kde.org>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  */
00019 #include "KoJobsListPolicy.h"
00020 #include <Job.h>
00021 
00022 using namespace ThreadWeaver;
00023 
00024 KoJobsListPolicy::KoJobsListPolicy() : mutex(QMutex::Recursive) {
00025 }
00026 
00027 bool KoJobsListPolicy::canRun (Job *job) {
00028     mutex.lock();
00029     bool rc = m_jobs.isEmpty() || m_jobs[0] == job;
00030     mutex.unlock();
00031     return rc;
00032 }
00033 
00034 void KoJobsListPolicy::free (Job *job) {
00035     Q_UNUSED(job);
00036     release(job);
00037 }
00038 
00039 void KoJobsListPolicy::release (Job *job) {
00040     mutex.lock();
00041     m_jobs.removeAll(job);
00042     job->deleteLater();
00043     mutex.unlock();
00044 }
00045 
00046 void KoJobsListPolicy::destructed (Job *job) {
00047     release(job);
00048 }
00049 
00050 const QList<Job*> KoJobsListPolicy::jobs() {
00051     QList<Job*> answer;
00052     mutex.lock();
00053     foreach(Job *job, m_jobs)
00054         answer.append(job);
00055     mutex.unlock();
00056     return answer;
00057 }
00058 
00059 void KoJobsListPolicy::addJob(Job *job) {
00060     mutex.lock();
00061     m_jobs.append(job);
00062     mutex.unlock();
00063 }
00064 
00065 int KoJobsListPolicy::count() {
00066     mutex.lock();
00067     int i = m_jobs.count();
00068     mutex.unlock();
00069     return i;
00070 }

Généré le Wed Nov 22 23:41:04 2006 pour KPlato par  doxygen 1.5.1-p1