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

ThreadWeaver

  • ThreadWeaver
  • ResourceRestrictionPolicy
Public Member Functions | List of all members
ThreadWeaver::ResourceRestrictionPolicy Class Reference

#include <ResourceRestrictionPolicy.h>

Inheritance diagram for ThreadWeaver::ResourceRestrictionPolicy:
Inheritance graph
[legend]

Public Member Functions

 ResourceRestrictionPolicy (int cap=0)
 
 ~ResourceRestrictionPolicy ()
 
bool canRun (Job *)
 
int cap () const
 
void destructed (Job *)
 
void free (Job *)
 
void release (Job *)
 
void setCap (int newCap)
 
- Public Member Functions inherited from ThreadWeaver::QueuePolicy
virtual ~QueuePolicy ()
 

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
newCapthe 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
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:53 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ThreadWeaver

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal