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

ThreadWeaver

ThreadWeaver::ResourceRestrictionPolicy

ThreadWeaver::ResourceRestrictionPolicy Class Reference

ResourceRestrictionPolicy is used to limit the number of concurrent accesses to the same resource. More...

#include <ResourceRestrictionPolicy.h>

Inheritance diagram for ThreadWeaver::ResourceRestrictionPolicy:

Inheritance graph
[legend]

List of all members.


Public Member Functions

bool canRun (Job *)
int cap () const
void destructed (Job *)
void free (Job *)
void release (Job *)
 ResourceRestrictionPolicy (int cap=0)
void setCap (int newCap)
 ~ResourceRestrictionPolicy ()

Detailed Description

ResourceRestrictionPolicy is used to limit the number of concurrent accesses to the same resource.

If a set of Jobs accesses a resource that can be overloaded, this may degrade application performance. For example, loading too many files from the hard disc at the same time may lead to longer load times. ResourceRestrictionPolicy can be used to cap the number of accesses. Resource restriction policies are shared between the affected jobs. All jobs that share a resurce restriction policy have to acquire permission from the policy before they can run. In this way, resource restrictions can be compared to semaphores, only that they require no locking at the thread level.

The SMIV example uses a resource restriction to limit the number of images files that are loaded from the disk at the same time.

Definition at line 54 of file ResourceRestrictionPolicy.h.


Constructor & Destructor Documentation

ResourceRestrictionPolicy::ResourceRestrictionPolicy ( int  cap = 0  )  [explicit]

Definition at line 50 of file ResourceRestrictionPolicy.cpp.

ResourceRestrictionPolicy::~ResourceRestrictionPolicy (  ) 

Definition at line 56 of file ResourceRestrictionPolicy.cpp.


Member Function Documentation

bool ResourceRestrictionPolicy::canRun ( Job *   )  [virtual]

canRun() is called before the job is executed.

The job will only be executed if canRun() returns true.

Implements ThreadWeaver::QueuePolicy.

Definition at line 73 of file ResourceRestrictionPolicy.cpp.

int ResourceRestrictionPolicy::cap (  )  const

Definition at line 67 of file ResourceRestrictionPolicy.cpp.

void ResourceRestrictionPolicy::destructed ( Job *   )  [virtual]

destructing() is called when a Job that has this queue policy assigned gets destructed.

Implements ThreadWeaver::QueuePolicy.

Definition at line 102 of file ResourceRestrictionPolicy.cpp.

void ResourceRestrictionPolicy::free ( Job *   )  [virtual]

free() is called after the job has been executed.

It is guaranteed that free is called only after canRun() returned true at an earlier time.

Implements ThreadWeaver::QueuePolicy.

Definition at line 85 of file ResourceRestrictionPolicy.cpp.

void ResourceRestrictionPolicy::release ( Job *   )  [virtual]

release() is called if canRun() returned true, but the job has not been executed for external reasons.

For example, a second QueuePolicy could have returned false from canRun() for the same job.

Implements ThreadWeaver::QueuePolicy.

Definition at line 97 of file ResourceRestrictionPolicy.cpp.

void ResourceRestrictionPolicy::setCap ( int  newCap  ) 

Cap the number of simulataniously executing jobs.

Capping the amount of jobs will make sure that at max the number of jobs executing at any time is limited to the capped amount. Note that immediately after setting the amount of running jobs may be higher than the set amount. This setting only limits the starting of new jobs.

Parameters:
newCap the new cap to limit the amount of parallel jobs.

Definition at line 61 of file ResourceRestrictionPolicy.cpp.


The documentation for this class was generated from the following files:
  • ResourceRestrictionPolicy.h
  • ResourceRestrictionPolicy.cpp

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