libzypp  13.10.6
zypp::base::InterProcessMutex Class Reference

Inter process scoped lock implementation. More...

#include <InterProcessMutex.h>

Inheritance diagram for zypp::base::InterProcessMutex:

Classes

class  Options
 options to alter the mutex behavor More...
 

Public Types

enum  ConsumerType { Reader, Writer }
 Processes can be of two types Reader or Writer. More...
 

Public Member Functions

 InterProcessMutex (const Options &poptions)
 Creates a mutex with a name and a timeout. More...
 
 ~InterProcessMutex ()
 Destructor, gives up the lock on the named resource. More...
 

Private Member Functions

bool isProcessRunning (pid_t pid_r)
 
Pathname lockFilePath () const
 

Private Attributes

shared_ptr< Fd_fd
 
Options _options
 

Detailed Description

Inter process scoped lock implementation.

This mutex will allow only one writer process to reach a critical region protected by a mutex of the same name, if there are no readers at the same time.

Multiple readers are allowed if there is no currently a writer.

Definition at line 43 of file InterProcessMutex.h.

Member Enumeration Documentation

Processes can be of two types Reader or Writer.

Enumerator
Reader 
Writer 

Definition at line 50 of file InterProcessMutex.h.

Constructor & Destructor Documentation

zypp::base::InterProcessMutex::InterProcessMutex ( const Options poptions)

Creates a mutex with a name and a timeout.

default timeout is -1 which means no timeout at all, and the mutex will wait forever if other process is accessing the critical region for a mutex in with the same name.

If the timeout is 0, then if the lock is acquired an exception will be thrown inmediately.

Otherwise, the timeout exception will come after the timeout is reached.

Definition at line 55 of file InterProcessMutex.cc.

zypp::base::InterProcessMutex::~InterProcessMutex ( )

Destructor, gives up the lock on the named resource.

Definition at line 284 of file InterProcessMutex.cc.

Member Function Documentation

bool zypp::base::InterProcessMutex::isProcessRunning ( pid_t  pid_r)
private

Definition at line 318 of file InterProcessMutex.cc.

Pathname zypp::base::InterProcessMutex::lockFilePath ( ) const
private

Definition at line 312 of file InterProcessMutex.cc.

Member Data Documentation

shared_ptr<Fd> zypp::base::InterProcessMutex::_fd
private

Definition at line 120 of file InterProcessMutex.h.

Options zypp::base::InterProcessMutex::_options
private

Definition at line 121 of file InterProcessMutex.h.


The documentation for this class was generated from the following files: