• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

ThreadWeaver

WorkingHardState.cpp

Go to the documentation of this file.
00001 /* -*- C++ -*-
00002 
00003 This file implements the WorkingHardState class.
00004 
00005 $ Author: Mirko Boehm $
00006 $ Copyright: (C) 2005, 2006 Mirko Boehm $
00007 $ Contact: mirko@kde.org
00008 http://www.kde.org
00009 http://www.hackerbuero.org $
00010 
00011    This library is free software; you can redistribute it and/or
00012    modify it under the terms of the GNU Library General Public
00013    License as published by the Free Software Foundation; either
00014    version 2 of the License, or (at your option) any later version.
00015 
00016    This library is distributed in the hope that it will be useful,
00017    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019    Library General Public License for more details.
00020 
00021    You should have received a copy of the GNU Library General Public License
00022    along with this library; see the file COPYING.LIB.  If not, write to
00023    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00024    Boston, MA 02110-1301, USA.
00025 
00026 $Id: WorkingHardState.cpp 30 2005-08-16 16:16:04Z mirko $
00027 */
00028 
00029 #include "WorkingHardState.h"
00030 
00031 #include <QtCore/QByteRef>
00032 
00033 #include "Job.h"
00034 #include "Thread.h"
00035 #include "WeaverImpl.h"
00036 #include "ThreadWeaver.h"
00037 #include "DebuggingAids.h"
00038 
00039 
00040 using namespace ThreadWeaver;
00041 
00042 void WorkingHardState::activated()
00043 {
00044     weaver()->assignJobs();
00045 }
00046 
00047 void WorkingHardState::suspend()
00048 {
00049     weaver()->setState ( Suspending );
00050 }
00051 
00052 void WorkingHardState::resume()
00053 {
00054 }
00055 
00056 Job* WorkingHardState::applyForWork ( Thread *th,  Job* )
00057 {   // beware: this code is executed in the applying thread!
00058     debug ( 2, "WorkingHardState::applyForWork: thread %i applies for work "
00059             "in %s state.\n", th->id(),
00060             qPrintable ( weaver()->state().stateName() ) );
00061 
00062     Job *next = weaver()->takeFirstAvailableJob();
00063 
00064     if ( next )
00065     {
00066         weaver()->incActiveThreadCount();
00067         return next;
00068     } else {
00069         debug ( 2, "WorkingHardState::applyForWork: no work for thread %i, "
00070                 "blocking it.\n", th->id() );
00071         weaver()->waitForAvailableJob( th );
00072         // this is no infinite recursion: the state may have changed
00073         // meanwhile, or jobs may have come available:
00074         return weaver()->applyForWork( th,  0 );
00075     }
00076 }
00077 
00078 void WorkingHardState::waitForAvailableJob ( Thread *th )
00079 {
00080     weaver()->blockThreadUntilJobsAreBeingAssigned ( th );
00081 }
00082 
00083 StateId WorkingHardState::stateId() const
00084 {
00085     return WorkingHard;
00086 }

ThreadWeaver

Skip menu "ThreadWeaver"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal