Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QFirebirdEventSubscription Class Reference
Inheritance diagram for QFirebirdEventSubscription:
Collaboration diagram for QFirebirdEventSubscription:

Public Member Functions

 QFirebirdEventSubscription (QFirebirdDriver *drv, IAttachment *att, const QString &eventName)
void addRef () override
int release () override
void eventCallbackFunction (unsigned length, const unsigned char *data) override
void stop ()
 QFirebirdEventSubscription (QFirebirdDriver *drv, IAttachment *att, const QString &eventName)
void addRef () override
int release () override
void eventCallbackFunction (unsigned length, const unsigned char *data) override
void stop ()

Public Attributes

QString name
QFirebirdDriverdriver = nullptr
IAttachment * attachment = nullptr
IEvents * events = nullptr
ISC_UCHAR * eventBuffer = nullptr
ISC_UCHAR * resultBuffer = nullptr
unsigned bufferLength = 0
bool first = true
std::atomic< int > counter = 0
std::mutex mutex

Detailed Description

Event notification support (OO API)

Follows the pattern from Firebird's examples/interfaces/08.events.cpp:

  • The subscription IS the callback (IEventCallback), ref-counted
  • eventCallbackFunction (Firebird thread) memcpy's result + posts; it holds a self-reference for its duration and a mutex around the buffer write and the driver-pointer use (stop() clears the pointer under the same mutex, so a returned stop() guarantees no callback still touches the driver)
  • isc_event_counts and re-registration happen on the main thread; the read takes the same mutex (re-arm does not — see qHandleEventNotification)
  • Only release(), never cancel(), is used on IEvents

Definition at line 63 of file qsql_firebird.cpp.

Constructor & Destructor Documentation

◆ QFirebirdEventSubscription() [1/2]

QFirebirdEventSubscription::QFirebirdEventSubscription ( QFirebirdDriver * drv,
IAttachment * att,
const QString & eventName )
inline

Definition at line 67 of file qsql_firebird.cpp.

References QFirebirdEventSubscription(), bufferLength, and driver.

Referenced by QFirebirdEventSubscription().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ QFirebirdEventSubscription() [2/2]

QFirebirdEventSubscription::QFirebirdEventSubscription ( QFirebirdDriver * drv,
IAttachment * att,
const QString & eventName )
inline

Definition at line 67 of file qsql_firebird.cpp.

Member Function Documentation

◆ addRef() [1/2]

void QFirebirdEventSubscription::addRef ( )
inlineoverride

Definition at line 77 of file qsql_firebird.cpp.

Referenced by eventCallbackFunction().

Here is the caller graph for this function:

◆ addRef() [2/2]

void QFirebirdEventSubscription::addRef ( )
inlineoverride

Definition at line 77 of file qsql_firebird.cpp.

◆ eventCallbackFunction() [1/2]

void QFirebirdEventSubscription::eventCallbackFunction ( unsigned length,
const unsigned char * data )
inlineoverride

IEventCallback — called on Firebird's internal event thread. Holds a self-reference for the duration so the owner thread's stop()/ release() cannot delete the subscription (and free resultBuffer) while this callback is still running. The mutex serialises the resultBuffer write against qHandleEventNotification's read on the owner thread, and covers the driver-pointer use: stop() clears the pointer under the same mutex, so the driver cannot be destroyed between the read and the invokeMethod. The queued invokeMethod only posts an event — it neither blocks nor re-enters Firebird — so holding the mutex across it cannot deadlock with the re-arm lock-ordering constraint.

Definition at line 98 of file qsql_firebird.cpp.

References addRef(), bufferLength, driver, and release().

Here is the call graph for this function:

◆ eventCallbackFunction() [2/2]

void QFirebirdEventSubscription::eventCallbackFunction ( unsigned length,
const unsigned char * data )
inlineoverride

IEventCallback — called on Firebird's internal event thread. Holds a self-reference for the duration so the owner thread's stop()/ release() cannot delete the subscription (and free resultBuffer) while this callback is still running. The mutex serialises the resultBuffer write against qHandleEventNotification's read on the owner thread, and covers the driver-pointer use: stop() clears the pointer under the same mutex, so the driver cannot be destroyed between the read and the invokeMethod. The queued invokeMethod only posts an event — it neither blocks nor re-enters Firebird — so holding the mutex across it cannot deadlock with the re-arm lock-ordering constraint.

Definition at line 98 of file qsql_firebird.cpp.

◆ release() [1/2]

int QFirebirdEventSubscription::release ( )
inlineoverride

Definition at line 78 of file qsql_firebird.cpp.

Referenced by eventCallbackFunction(), and QFirebirdDriver::unsubscribeFromNotification().

Here is the caller graph for this function:

◆ release() [2/2]

int QFirebirdEventSubscription::release ( )
inlineoverride

Definition at line 78 of file qsql_firebird.cpp.

◆ stop() [1/2]

void QFirebirdEventSubscription::stop ( )
inline

Disconnect from the driver so the callback no longer posts to it, and release the IEvents handle (no cancel — avoids Firebird internal lock contention that causes crashes on Windows). Clearing the pointer under the mutex waits out any in-flight callback that already loaded it, so after stop() returns the driver can be destroyed safely.

Definition at line 124 of file qsql_firebird.cpp.

References driver.

Referenced by QFirebirdDriver::unsubscribeFromNotification().

Here is the caller graph for this function:

◆ stop() [2/2]

void QFirebirdEventSubscription::stop ( )
inline

Disconnect from the driver so the callback no longer posts to it, and release the IEvents handle (no cancel — avoids Firebird internal lock contention that causes crashes on Windows). Clearing the pointer under the mutex waits out any in-flight callback that already loaded it, so after stop() returns the driver can be destroyed safely.

Definition at line 124 of file qsql_firebird.cpp.

Member Data Documentation

◆ attachment

IAttachment * QFirebirdEventSubscription::attachment = nullptr

Definition at line 139 of file qsql_firebird.cpp.

◆ bufferLength

unsigned QFirebirdEventSubscription::bufferLength = 0

Definition at line 143 of file qsql_firebird.cpp.

Referenced by QFirebirdEventSubscription(), and eventCallbackFunction().

◆ counter

std::atomic< int > QFirebirdEventSubscription::counter = 0

Definition at line 145 of file qsql_firebird.cpp.

◆ driver

QFirebirdDriver * QFirebirdEventSubscription::driver = nullptr

Definition at line 137 of file qsql_firebird.cpp.

Referenced by QFirebirdEventSubscription(), eventCallbackFunction(), and stop().

◆ eventBuffer

ISC_UCHAR * QFirebirdEventSubscription::eventBuffer = nullptr

Definition at line 141 of file qsql_firebird.cpp.

◆ events

IEvents * QFirebirdEventSubscription::events = nullptr

Definition at line 140 of file qsql_firebird.cpp.

◆ first

bool QFirebirdEventSubscription::first = true

Definition at line 144 of file qsql_firebird.cpp.

◆ mutex

std::mutex QFirebirdEventSubscription::mutex

Definition at line 146 of file qsql_firebird.cpp.

◆ name

QString QFirebirdEventSubscription::name

◆ resultBuffer

ISC_UCHAR * QFirebirdEventSubscription::resultBuffer = nullptr

Definition at line 142 of file qsql_firebird.cpp.


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