Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSafeReadList< T > Class Template Reference

#include <kis_safe_read_list.h>

+ Inheritance diagram for KisSafeReadList< T >:

Public Member Functions

const T & at (int i) const
 
const T & first () const
 
 KisSafeReadList ()
 
const T & last () const
 

Detailed Description

template<class T>
class KisSafeReadList< T >

This is a special wrapper around QList class Q: Why is it needed? A: It guarantees thread-safety of all the read requests to the list. There is absolutely no guarantees for write requests though. Q: Why pure QList cannot guarantee it? A: First, Qt does not guarantee thread-safety for QList at all. Second, QList is implicitly shared structure, therefore even with read, but non-const requests (e.g. non-const QList::first()), QList will perform internal write operations. That will lead to a race condition in an environment with 3 and more threads.

Definition at line 27 of file kis_safe_read_list.h.

Constructor & Destructor Documentation

◆ KisSafeReadList()

template<class T >
KisSafeReadList< T >::KisSafeReadList ( )
inline

Definition at line 29 of file kis_safe_read_list.h.

29{}

Member Function Documentation

◆ at()

template<class T >
const T & KisSafeReadList< T >::at ( int i) const
inline

Definition at line 54 of file kis_safe_read_list.h.

54 {
55 return QList<T>::at(i);
56 }

◆ first()

template<class T >
const T & KisSafeReadList< T >::first ( ) const
inline

All the methods of this class are split into two groups: threadsafe and non-threadsafe. The methods from the first group can be called concurrently with each other. The ones form the other group can't be called concurrently (even with the friends from the first group) and must have an exclusive access to the list. The thread-safe group

Definition at line 46 of file kis_safe_read_list.h.

46 {
47 return QList<T>::first();
48 }

◆ last()

template<class T >
const T & KisSafeReadList< T >::last ( ) const
inline

Definition at line 50 of file kis_safe_read_list.h.

50 {
51 return QList<T>::last();
52 }

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