Qore Programming Language Reference Manual  1.7.0
Qore::StreamBase Class Reference

This class defines the API for single thread streams. More...

Inheritance diagram for Qore::StreamBase:

Public Member Methods

 constructor ()
 Throws an exception if called directly; this class can only be instantiated by builtin subclasses. More...
 
int getThreadId ()
 Get the currently assigned thread id or -1 if not assigned to any thread.
 
nothing reassignThread ()
 Reassigns current thread as thread used for stream manipulation. More...
 
nothing unassignThread ()
 Unassigns current thread as thread used for stream manipulation. More...
 

Detailed Description

This class defines the API for single thread streams.

Base class for stream classes which are not designed to be accessed from multiple threads; they have been implemented without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause a STREAM-THREAD-ERROR to be thrown, unless the stream is handed off to another thread using the StreamBase::unassignThread() method in the thread that currently owns the stream, and the StreamBase::reassignThread() method in the new thread.

Since
Qore 0.9

Member Function Documentation

◆ constructor()

Qore::StreamBase::constructor ( )

Throws an exception if called directly; this class can only be instantiated by builtin subclasses.

Exceptions
STREAMBASE-CONSTRUCTOR-ERRORthis exception is thrown if this class is constructed directly (also if directly inherited by user classes)

◆ reassignThread()

nothing Qore::StreamBase::reassignThread ( )

Reassigns current thread as thread used for stream manipulation.

This method must be called from the new thread after calling the StreamBase::unassignThread() method in the thread that currently owns the stream

Exceptions
STREAM-THREAD-ERRORthrown if called when the stream is assigned to another thread
See also
StreamBase::unassignThread()

◆ unassignThread()

nothing Qore::StreamBase::unassignThread ( )

Unassigns current thread as thread used for stream manipulation.

This method must be called in the current thread that owns the stream before calling the StreamBase::reassignThread() method in the new thread

Exceptions
STREAM-THREAD-ERRORthrown if called when the stream is assigned to another thread
See also
StreamBase::reassignThread()