# class MutexModel

###

Module | soprano
Namespace | Soprano::Util
Class | MutexModel
Inherits | Soprano::FilterModel

\class MutexModel mutexmodel.h Soprano/Util/MutexModel

Protect a Model for multiple calls in multi-threaded 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. It may, however, come in handy for custom models.

Author Sebastian Trueg <trueg@kde.org>

### enums

- ProtectionMode { PlainMultiThreading, ReadWriteMultiThreading, ReadWriteSingleThreading }

enum details

### methods

- MutexModel (mode, parent)

  returns ctor

  Argument | Type | Default
  --- | --- | ---
  mode | Soprano.Util.MutexModel.ProtectionMode |
  parent | Soprano.Model | 0

  Create a new MutexModel.

  mode - The mode to use.

  parent - The parent Model to forward the actual calls to.

- addStatement (statement)

  returns Soprano.Error.ErrorCode

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

- containsAnyStatement (statement)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

- containsStatement (statement)

  returns bool

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

- executeQuery (query, language, userQueryLanguage)

  returns Soprano.QueryResultIterator

  Argument | Type | Default
  --- | --- | ---
  query | QString |
  language | Soprano.Query.QueryLanguage |
  userQueryLanguage | QString | QString()

- isEmpty ( )

  returns bool

- listContexts ( )

  returns Soprano.NodeIterator

- listStatements (partial)

  returns Soprano.StatementIterator

  Argument | Type | Default
  --- | --- | ---
  partial | Soprano.Statement |

- removeAllStatements (statement)

  returns Soprano.Error.ErrorCode

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

- removeStatement (statement)

  returns Soprano.Error.ErrorCode

  Argument | Type | Default
  --- | --- | ---
  statement | Soprano.Statement |

- statementCount ( )

  returns int

### enums - detail

- ProtectionMode { PlainMultiThreading, ReadWriteMultiThreading, ReadWriteSingleThreading }

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

  In this mode nesting iterators will result in a deadlock.

  | PlainMultiThreading | - | - |
  | ReadWriteMultiThreading | - | - |
  | ReadWriteSingleThreading | - | - |