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

#include <qsbr.h>

Classes

struct  Action
 

Public Member Functions

template<class T >
void enqueue (void(T::*pmf)(), T *target, bool migration=false)
 
void flush ()
 
void lockRawPointerAccess ()
 
bool sanityRawPointerAccessLocked () const
 
void unlockRawPointerAccess ()
 
void update ()
 

Private Member Functions

void releasePoolSafely (KisLocklessStack< Action > *pool, bool force=false)
 

Private Attributes

KisLocklessStack< Actionm_migrationReclaimActions
 
KisLocklessStack< Actionm_pendingActions
 
QAtomicInt m_rawPointerUsers
 

Detailed Description

Definition at line 18 of file qsbr.h.

Member Function Documentation

◆ enqueue()

template<class T >
void QSBR::enqueue ( void(T::*)() pmf,
T * target,
bool migration = false )
inline

Definition at line 71 of file qsbr.h.

72 {
73 struct Closure {
74 void (T::*pmf)();
75 T* target;
76
77 static void thunk(void* param)
78 {
79 Closure* self = (Closure*) param;
80 CALL_MEMBER(*self->target, self->pmf)();
81 }
82 };
83
84 Closure closure = {pmf, target};
85
86 if (migration) {
87 m_migrationReclaimActions.push(Action(Closure::thunk, &closure, sizeof(closure)));
88 } else {
89 m_pendingActions.push(Action(Closure::thunk, &closure, sizeof(closure)));
90 }
91 }
KisMagneticGraph::vertex_descriptor target(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
KisLocklessStack< Action > m_pendingActions
Definition qsbr.h:40
KisLocklessStack< Action > m_migrationReclaimActions
Definition qsbr.h:41
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
#define CALL_MEMBER(obj, pmf)
Definition qsbr.h:16

References CALL_MEMBER, m_migrationReclaimActions, m_pendingActions, target(), and void().

◆ flush()

void QSBR::flush ( )
inline

Definition at line 99 of file qsbr.h.

100 {
103 }
void releasePoolSafely(KisLocklessStack< Action > *pool, bool force=false)
Definition qsbr.h:43

References m_migrationReclaimActions, m_pendingActions, and releasePoolSafely().

◆ lockRawPointerAccess()

void QSBR::lockRawPointerAccess ( )
inline

Definition at line 105 of file qsbr.h.

106 {
107 m_rawPointerUsers.ref();
108 }
QAtomicInt m_rawPointerUsers
Definition qsbr.h:39

References m_rawPointerUsers.

◆ releasePoolSafely()

void QSBR::releasePoolSafely ( KisLocklessStack< Action > * pool,
bool force = false )
inlineprivate

Definition at line 43 of file qsbr.h.

43 {
45 tmp.mergeFrom(*pool);
46 if (tmp.isEmpty()) return;
47
48 if (force || tmp.size() > 4096) {
49 while (m_rawPointerUsers.loadAcquire());
50
51 Action action;
52 while (tmp.pop(action)) {
53 action();
54 }
55 } else {
56 if (!m_rawPointerUsers.loadAcquire()) {
57 Action action;
58 while (tmp.pop(action)) {
59 action();
60 }
61 } else {
62 // push elements back to the source
63 pool->mergeFrom(tmp);
64 }
65 }
66 }
void mergeFrom(KisLocklessStack< T > &other)

References m_rawPointerUsers, and KisLocklessStack< T >::mergeFrom().

◆ sanityRawPointerAccessLocked()

bool QSBR::sanityRawPointerAccessLocked ( ) const
inline

Definition at line 115 of file qsbr.h.

115 {
116 return m_rawPointerUsers.loadAcquire();
117 }

References m_rawPointerUsers.

◆ unlockRawPointerAccess()

void QSBR::unlockRawPointerAccess ( )
inline

Definition at line 110 of file qsbr.h.

111 {
112 m_rawPointerUsers.deref();
113 }

References m_rawPointerUsers.

◆ update()

void QSBR::update ( )
inline

Member Data Documentation

◆ m_migrationReclaimActions

KisLocklessStack<Action> QSBR::m_migrationReclaimActions
private

Definition at line 41 of file qsbr.h.

◆ m_pendingActions

KisLocklessStack<Action> QSBR::m_pendingActions
private

Definition at line 40 of file qsbr.h.

◆ m_rawPointerUsers

QAtomicInt QSBR::m_rawPointerUsers
private

Definition at line 39 of file qsbr.h.


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