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

KDECore

Public Types | Public Member Functions | List of all members
KLockFile Class Reference

#include <KLockFile>

Inheritance diagram for KLockFile:
Inheritance graph
[legend]

Public Types

enum  LockFlag { NoBlockFlag = 1, ForceFlag = 2 }
 
enum  LockResult { LockOK = 0, LockFail, LockError, LockStale }
 
typedef KSharedPtr< KLockFile > Ptr
 

Public Member Functions

 KLockFile (const QString &file, const KComponentData &componentName=KGlobal::mainComponent())
 
 ~KLockFile ()
 
bool getLockInfo (int &pid, QString &hostname, QString &appname)
 
bool isLocked () const
 
LockResult lock (LockFlags flags=LockFlags())
 
void setStaleTime (int _staleTime)
 
int staleTime () const
 
void unlock ()
 
- Public Member Functions inherited from QSharedData
 QSharedData ()
 
 QSharedData (const QSharedData &other)
 

Detailed Description

The KLockFile class provides NFS safe lockfiles.

Author
Waldo Bastian basti.nosp@m.an@k.nosp@m.de.or.nosp@m.g

Definition at line 36 of file klockfile.h.

Member Typedef Documentation

typedef KSharedPtr<KLockFile> KLockFile::Ptr

Definition at line 39 of file klockfile.h.

Member Enumeration Documentation

enum KLockFile::LockFlag
Enumerator
NoBlockFlag 

Return immediately, do not wait for the lock to become available.

ForceFlag 

Automatically remove a lock when a lock is detected that is stale for more than staleTime() seconds, or if the process that created it is not running anymore.

Definition at line 73 of file klockfile.h.

enum KLockFile::LockResult

Possible return values of the lock function.

Enumerator
LockOK 

Lock was acquired successfully.

LockFail 

The lock could not be acquired because it is held by another process.

LockError 

The lock could not be acquired due to an error.

LockStale 

A stale lock has been detected.

Definition at line 51 of file klockfile.h.

Constructor & Destructor Documentation

KLockFile::KLockFile ( const QString &  file,
const KComponentData &  componentName = KGlobal::mainComponent() 
)
explicit

Definition at line 116 of file klockfile_unix.cpp.

KLockFile::~KLockFile ( )

Destroys the object, releasing the lock if held.

Definition at line 122 of file klockfile_unix.cpp.

Member Function Documentation

bool KLockFile::getLockInfo ( int &  pid,
QString &  hostname,
QString &  appname 
)

Returns the pid, hostname and appname of the process holding the lock after the lock functon has returned with LockStale.

Returns
false if the pid and hostname could not be determined

Definition at line 502 of file klockfile_unix.cpp.

bool KLockFile::isLocked ( ) const

Returns whether the lock is held or not.

Definition at line 482 of file klockfile_unix.cpp.

KLockFile::LockResult KLockFile::lock ( LockFlags  flags = LockFlags())

Attempt to acquire the lock.

Parameters
flagsA set of LockFlag values OR'ed together.

Definition at line 386 of file klockfile_unix.cpp.

void KLockFile::setStaleTime ( int  _staleTime)

Set the time in seconds after which a lock is considered stale.

Definition at line 136 of file klockfile_unix.cpp.

int KLockFile::staleTime ( ) const

Return the time in seconds after which a lock is considered stale The default is 30.

Definition at line 129 of file klockfile_unix.cpp.

void KLockFile::unlock ( )

Release the lock.

Definition at line 487 of file klockfile_unix.cpp.


The documentation for this class was generated from the following files:
  • klockfile.h
  • klockfile_unix.cpp
  • klockfile_win.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • 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
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • 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