WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. | Zuble QML Types | Zuble C++ Classes | Zuble Overview |
Zuble
0.1
Zuble Framework C++/QML extension API
|
A class to manage Zuble's thread-specific state. This includes error propagation and thread abort handling. More...
#include <ZblThreadErr.h>
Signals | |
void | notifyError (const ZblError &error) |
Sent when an error condition has been set. More... | |
void | notifyClearError () |
Sent when an error condition has been cleared. More... | |
void | notifyAbort () |
Sent when an abort is requested. More... | |
Public Member Functions | |
const ZblError & | error () const |
Returns a reference to the ZblError instance for the current thread. More... | |
void | raiseError (const QString &facility, const QString &code, const QString &message) |
Sets the current thread's error information and issues the notifyError signal. More... | |
void | raiseError (const char *facility, const char *code, const char *message) |
Sets the current thread's error information and issues the notifyError signal. More... | |
void | raiseError (const QString &message) |
Sets the current thread's error information and issues the notifyError signal. More... | |
void | raiseError (const char *message) |
Sets the current thread's error information and issues the notifyError signal. More... | |
void | clearError () |
Sets the current thread's error status to normal and issues the notifyClearError signal. More... | |
bool | isError () |
Test if an error condition exists. More... | |
QString | getErrorMessage () |
Obtain a formatted error message. More... | |
void | abort () |
Sets the current thread's error status to abort and issues the notifyAbort signal. More... | |
bool | isAborting () |
Test if an abort condition exists. More... | |
Static Public Member Functions | |
static void | zInit () |
This method must be called once at the start of each thread that throws or catches ZblException objects or otherwise uses ZblThreadErr for error propagation. More... | |
static ZblThreadErr & | zInstance () |
Returns a reference to the ZblThreadErr instance for the current thread. More... | |
Private Member Functions | |
void | logError () |
ZblThreadErr (QObject *parent=0) | |
Don't construct this. Call static zInstance() method or use the zThreadErr macro definition instead. More... | |
Private Attributes | |
ZblError | m_error |
The error object for this thread. More... | |
bool | m_aborting |
Aborting flag fo this thread. More... | |
Static Private Attributes | |
static ZblLogCategory | m_log |
static QThreadStorage< ZblThreadErr * > | m_zThreads |
A set of ZblThreadErr object pointers in thread local storage. More... | |
A class to manage Zuble's thread-specific state. This includes error propagation and thread abort handling.
Each thread that participates in the Zuble error propagation system must instanciate one and only one of these objects. The ZblThreadErr object is a per-thread singleton that installs itself in thread local storage when it's created.
ZblThreadErr encapsulates the ZblError object and propagates signals related to error status changes on a per-thread basis.
Due to Qt limitations on exception handling (parts of Qt will abort when an exception is thrown) Zuble uses a dual-mode error propagation system that supports both exceptions (ZblException) and use of a shared error object (ZblError).
Each Zuble thread maintains a single instance of the ZblError object and all ZblException instances refer to the thread-specific ZblError object when they're thrown. This allows an exception's error information to exceed the lifetime of the ZblException object that produced it.
Slots in QObjects that may throw exceptions need to safeguard such code with try/catch blocks and return "undefined" variants or otherwise indicate a failure status to the caller.
Callers of Slots (or any code) may call zThreadErr.isError() and zThreadErr.isAborting() to determine status conditions for the current thread.
Signals:
An error alert signal allows a way for objects to be alerted when an error condition is raised.
A thread abort signal allows objects to detect when a thread should be aborted.
Definition at line 87 of file ZblThreadErr.h.
|
explicitprivate |
Don't construct this. Call static zInstance() method or use the zThreadErr macro definition instead.
parent |
Definition at line 54 of file ZblThreadErr.cpp.
Referenced by zInit().
void Zbl::ZblThreadErr::abort | ( | ) |
Sets the current thread's error status to abort and issues the notifyAbort signal.
Definition at line 133 of file ZblThreadErr.cpp.
void Zbl::ZblThreadErr::clearError | ( | ) |
Sets the current thread's error status to normal and issues the notifyClearError signal.
Definition at line 111 of file ZblThreadErr.cpp.
const ZblError & Zbl::ZblThreadErr::error | ( | ) | const |
Returns a reference to the ZblError instance for the current thread.
Definition at line 69 of file ZblThreadErr.cpp.
QString Zbl::ZblThreadErr::getErrorMessage | ( | ) |
Obtain a formatted error message.
Definition at line 126 of file ZblThreadErr.cpp.
bool Zbl::ZblThreadErr::isAborting | ( | ) |
Test if an abort condition exists.
Definition at line 140 of file ZblThreadErr.cpp.
bool Zbl::ZblThreadErr::isError | ( | ) |
Test if an error condition exists.
Definition at line 121 of file ZblThreadErr.cpp.
|
private |
Definition at line 62 of file ZblThreadErr.cpp.
Referenced by raiseError().
|
signal |
Sent when an abort is requested.
Referenced by abort().
|
signal |
Sent when an error condition has been cleared.
Referenced by clearError().
|
signal |
Sent when an error condition has been set.
A | reference to the error |
Referenced by raiseError().
void Zbl::ZblThreadErr::raiseError | ( | const QString & | facility, |
const QString & | code, | ||
const QString & | message | ||
) |
Sets the current thread's error information and issues the notifyError signal.
facility | The module, code library or application name |
code | The error code or error number |
message | The error message |
Definition at line 74 of file ZblThreadErr.cpp.
void Zbl::ZblThreadErr::raiseError | ( | const char * | facility, |
const char * | code, | ||
const char * | message | ||
) |
Sets the current thread's error information and issues the notifyError signal.
facility | The module, code library or application name |
code | The error code or error number |
message | The error message |
Definition at line 85 of file ZblThreadErr.cpp.
void Zbl::ZblThreadErr::raiseError | ( | const QString & | message | ) |
Sets the current thread's error information and issues the notifyError signal.
message | The error message |
Definition at line 96 of file ZblThreadErr.cpp.
void Zbl::ZblThreadErr::raiseError | ( | const char * | message | ) |
Sets the current thread's error information and issues the notifyError signal.
message | The error message |
Definition at line 103 of file ZblThreadErr.cpp.
|
static |
This method must be called once at the start of each thread that throws or catches ZblException objects or otherwise uses ZblThreadErr for error propagation.
Definition at line 38 of file ZblThreadErr.cpp.
Referenced by Zbl::ZScriptWorker::onStarted(), Zbl::Zblcore::registerTypes(), and zInstance().
|
static |
Returns a reference to the ZblThreadErr instance for the current thread.
Definition at line 46 of file ZblThreadErr.cpp.
|
private |
Aborting flag fo this thread.
Definition at line 238 of file ZblThreadErr.h.
Referenced by abort(), and isAborting().
|
private |
The error object for this thread.
Definition at line 232 of file ZblThreadErr.h.
Referenced by clearError(), error(), getErrorMessage(), isError(), logError(), and raiseError().
|
staticprivate |
Definition at line 211 of file ZblThreadErr.h.
Referenced by logError(), and ZblThreadErr().
|
staticprivate |
A set of ZblThreadErr object pointers in thread local storage.
Definition at line 226 of file ZblThreadErr.h.
Referenced by zInit(), and zInstance().
Zuble documentation copyright © 2019 Bob Dinitto. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Zuble is a derivative work of Qt version 5. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.