Krita Source Code Documentation
Loading...
Searching...
No Matches
SimpleCache Class Reference

#include <kis_tile_data_interface.h>

Public Member Functions

void clear ()
 
bool pop (int pixelSize, quint8 *&ptr)
 
bool push (int pixelSize, quint8 *&ptr)
 
 SimpleCache ()=default
 
 ~SimpleCache ()
 

Private Attributes

KisLocklessStack< quint8 * > m_16Pool
 
KisLocklessStack< quint8 * > m_4Pool
 
KisLocklessStack< quint8 * > m_8Pool
 
QReadWriteLock m_cacheLock
 

Detailed Description

Definition at line 34 of file kis_tile_data_interface.h.

Constructor & Destructor Documentation

◆ SimpleCache()

SimpleCache::SimpleCache ( )
default

◆ ~SimpleCache()

SimpleCache::~SimpleCache ( )

Definition at line 29 of file kis_tile_data.cc.

30{
31 clear();
32}

References clear().

Member Function Documentation

◆ clear()

void SimpleCache::clear ( )

Definition at line 34 of file kis_tile_data.cc.

35{
36 QWriteLocker l(&m_cacheLock);
37 quint8 *ptr = 0;
38
39 while (m_4Pool.pop(ptr)) {
40 BoostPool4BPP::free(ptr);
41 }
42
43 while (m_8Pool.pop(ptr)) {
44 BoostPool8BPP::free(ptr);
45 }
46
47 while (m_16Pool.pop(ptr)) {
48 free(ptr);
49 }
50}
KisLocklessStack< quint8 * > m_16Pool
QReadWriteLock m_cacheLock
KisLocklessStack< quint8 * > m_4Pool
KisLocklessStack< quint8 * > m_8Pool

References m_16Pool, m_4Pool, m_8Pool, m_cacheLock, and KisLocklessStack< T >::pop().

◆ pop()

bool SimpleCache::pop ( int pixelSize,
quint8 *& ptr )
inline

Definition at line 60 of file kis_tile_data_interface.h.

61 {
62 QReadLocker l(&m_cacheLock);
63 switch (pixelSize) {
64 case 4:
65 return m_4Pool.pop(ptr);
66 case 8:
67 return m_8Pool.pop(ptr);
68 case 16:
69 return m_16Pool.pop(ptr);
70 default:
71 return false;
72 }
73 }

References m_16Pool, m_4Pool, m_8Pool, m_cacheLock, and KisLocklessStack< T >::pop().

◆ push()

bool SimpleCache::push ( int pixelSize,
quint8 *& ptr )
inline

Definition at line 40 of file kis_tile_data_interface.h.

41 {
42 QReadLocker l(&m_cacheLock);
43 switch (pixelSize) {
44 case 4:
45 m_4Pool.push(ptr);
46 break;
47 case 8:
48 m_8Pool.push(ptr);
49 break;
50 case 16:
51 m_16Pool.push(ptr);
52 break;
53 default:
54 return false;
55 }
56
57 return true;
58 }

References m_16Pool, m_4Pool, m_8Pool, m_cacheLock, and KisLocklessStack< T >::push().

Member Data Documentation

◆ m_16Pool

KisLocklessStack<quint8*> SimpleCache::m_16Pool
private

Definition at line 81 of file kis_tile_data_interface.h.

◆ m_4Pool

KisLocklessStack<quint8*> SimpleCache::m_4Pool
private

Definition at line 79 of file kis_tile_data_interface.h.

◆ m_8Pool

KisLocklessStack<quint8*> SimpleCache::m_8Pool
private

Definition at line 80 of file kis_tile_data_interface.h.

◆ m_cacheLock

QReadWriteLock SimpleCache::m_cacheLock
private

Definition at line 78 of file kis_tile_data_interface.h.


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