Soprano::Util::MutexModel Class Reference

Protect a Model for multiple calls in multi- or single-thread applications. More...

#include <Soprano/Util/MutexModel>

Inheritance diagram for Soprano::Util::MutexModel:
[legend]

List of all members.

Public Types

enum  ProtectionMode { PlainMultiThreading, ReadWriteMultiThreading, ReadWriteSingleThreading }

Public Member Functions

 MutexModel (ProtectionMode mode, Model *parent=0)
 ~MutexModel ()
Error::ErrorCode addStatement (const Statement &statement)
Error::ErrorCode removeStatement (const Statement &statement)
Error::ErrorCode removeAllStatements (const Statement &statement)
StatementIterator listStatements (const Statement &partial) const
NodeIterator listContexts () const
QueryResultIterator executeQuery (const QString &query, Query::QueryLanguage language, const QString &userQueryLanguage=QString()) const
bool containsStatement (const Statement &statement) const
bool containsAnyStatement (const Statement &statement) const
bool isEmpty () const
int statementCount () const


Detailed Description

Protect a Model for multiple calls in multi- or single-thread applications.

In most cases one does not need to use this FilterModel since Models created by Soprano::createModel and Soprano::Backend::createModel are thread-safe.

Author:
Sebastian Trueg <trueg@kde.org>

Definition at line 44 of file mutexmodel.h.


Member Enumeration Documentation

enum Soprano::Util::MutexModel::ProtectionMode

Enumerator:
PlainMultiThreading  In PlainMultiThreading mode only one action can be performed at the same time. Calls block until the previous call is done.

Warning:
In this mode nesting iterators will result in a deadlock.
ReadWriteMultiThreading  In ReadWriteMultiThreading mode multiple read operations can be performed at the same time but only one write operation.
ReadWriteSingleThreading  ReadWriteSingleThreading mode is targetted at single thread applications. It makes sure that no read and write operations are performed interweaved. This mainly means that an open iterator will block any write operation. Blocked operations wait in a local event loop. Thus, the application is not entirely blocked.

This mode is mainly useful for server applications that need to handle multiple clients at the same time in the same thread. Actually the Soprano::Server implementation does make use of MutexModel with this mode.

Warning:
In ReadWriteSingleThreading mode MutexModel is not thread-safe.

Definition at line 49 of file mutexmodel.h.


Constructor & Destructor Documentation

Soprano::Util::MutexModel::MutexModel ( ProtectionMode  mode,
Model parent = 0 
)

Create a new MutexModel.

Parameters:
mode The mode to use.
parent The parent Model to forward the actual calls to.

Soprano::Util::MutexModel::~MutexModel (  ) 

Destructor.


Member Function Documentation

Error::ErrorCode Soprano::Util::MutexModel::addStatement ( const Statement statement  )  [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

Error::ErrorCode Soprano::Util::MutexModel::removeStatement ( const Statement statement  )  [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

Error::ErrorCode Soprano::Util::MutexModel::removeAllStatements ( const Statement statement  )  [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

StatementIterator Soprano::Util::MutexModel::listStatements ( const Statement partial  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

NodeIterator Soprano::Util::MutexModel::listContexts (  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

QueryResultIterator Soprano::Util::MutexModel::executeQuery ( const QString query,
Query::QueryLanguage  language,
const QString userQueryLanguage = QString() 
) const [virtual]

Default implementation simply pipes the call through to the parent model. Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

bool Soprano::Util::MutexModel::containsStatement ( const Statement statement  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

bool Soprano::Util::MutexModel::containsAnyStatement ( const Statement statement  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

bool Soprano::Util::MutexModel::isEmpty (  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.

int Soprano::Util::MutexModel::statementCount (  )  const [virtual]

Default implementation simply pipes the call through to the parent model.

Reimplemented from Soprano::FilterModel.


The documentation for this class was generated from the following file:
Generated on Fri Mar 7 18:57:48 2008 for Soprano by  doxygen 1.5.4