32#ifndef _QORE_STREAMBASE_H 
   33#define _QORE_STREAMBASE_H 
   35#include "qore/AbstractPrivateData.h" 
   37#include "qore/QoreString.h" 
   38#include "qore/ExceptionSink.h" 
   39#include "qore/BinaryNode.h" 
   58        if (tid.load(std::memory_order_relaxed) != 
q_gettid()) {
 
   59            xsink->
raiseException(
"STREAM-THREAD-ERROR", 
"this %s object was created in TID %d; it is an error " \
 
   60                "to access it from any other thread (accessed from TID %d)", 
getName(),
 
   61                tid.load(std::memory_order_relaxed), 
q_gettid());
 
   75        if (!tid.compare_exchange_strong(chktid, 
q_gettid(), std::memory_order_consume, std::memory_order_relaxed)) {
 
   78                xsink->
raiseException(
"STREAM-THREAD-ERROR", 
"this %s object is assigned to TID %d; it is an error " \
 
   79                    "to access it from any other thread (accessed from TID %d)", 
getName(), chktid, 
q_gettid());
 
   92        if (!tid.compare_exchange_strong(chktid, -1, std::memory_order_release, std::memory_order_relaxed)) {
 
   95                xsink->
raiseException(
"STREAM-THREAD-ERROR", 
"this %s object is assigned to TID %d; unassignment may " \
 
   96                    "be processed from that thread (accessed from TID %d)", 
getName(), chktid, 
q_gettid());
 
  105        return tid.load(std::memory_order_relaxed);
 
  127    std::atomic<int> tid;
 
the base class for all data to be used as private data of Qore objects
Definition: AbstractPrivateData.h:44
 
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:50
 
DLLEXPORT AbstractQoreNode * raiseException(const char *err, const char *fmt,...)
appends a Qore-language exception to the list
 
defines a Qore-language class
Definition: QoreClass.h:249
 
Base class for private data of stream implementations in C++.
Definition: StreamBase.h:48
 
DLLLOCAL int getThreadId()
Get currently assigned thread id.
Definition: StreamBase.h:104
 
StreamBase()
Constructor.
Definition: StreamBase.h:118
 
DLLLOCAL bool check(ExceptionSink *xsink)
Checks that the current thread is the same as when the instance was created or assigned via unassignT...
Definition: StreamBase.h:57
 
DLLLOCAL void reassignThread(ExceptionSink *xsink)
Reassigns current thread as thread used for stream manipulation, see check()
Definition: StreamBase.h:72
 
virtual DLLLOCAL const char * getName()=0
Returns the name of the class.
 
DLLLOCAL void unassignThread(ExceptionSink *xsink)
Unassigns current thread as thread used for stream manipulation, see check()
Definition: StreamBase.h:89
 
DLLEXPORT int q_gettid() noexcept
returns the current TID number