Yate
ThreadedSource Class Referenceabstract

Data source with own thread. More...

#include <yatephone.h>

Inheritance diagram for ThreadedSource:
DataSource DataNode Mutex RefObject Lockable GenObject

Public Member Functions

virtual void destroyed ()
bool start (const char *name="ThreadedSource", Thread::Priority prio=Thread::Normal)
void stop ()
Threadthread () const
bool running () const
Public Member Functions inherited from DataSource
 DataSource (const char *format="slin")
virtual void * getObject (const String &name) const
virtual bool valid () const
virtual bool control (NamedList &params)
unsigned long Forward (const DataBlock &data, unsigned long tStamp=invalidStamp(), unsigned long flags=0)
bool attach (DataConsumer *consumer, bool override=false)
bool detach (DataConsumer *consumer)
void clear ()
DataTranslator * getTranslator () const
void synchronize (unsigned long tStamp)
unsigned long nextStamp () const
Public Member Functions inherited from DataNode
 DataNode (const char *format=0)
virtual int costFormat (const DataFormat &format)
virtual bool setFormat (const DataFormat &format)
const DataFormatgetFormat () const
unsigned long timeStamp () const
virtual void attached (bool added)
Public Member Functions inherited from RefObject
 RefObject ()
virtual ~RefObject ()
virtual bool alive () const
bool ref ()
bool deref ()
int refcount () const
virtual void destruct ()
Public Member Functions inherited from GenObject
 GenObject ()
virtual ~GenObject ()
virtual const StringtoString () const
virtual const StringtraceId () const
NamedCountergetObjCounter () const
NamedCountersetObjCounter (NamedCounter *counter)
Public Member Functions inherited from Mutex
 Mutex (bool recursive=false, const char *name=0)
 Mutex (const Mutex &original)
 ~Mutex ()
Mutexoperator= (const Mutex &original)
virtual bool lock (long maxwait=-1)
virtual bool unlock ()
virtual bool locked () const
const char * owner () const
bool recursive () const
virtual MutexlockableMutex ()
Public Member Functions inherited from Lockable
virtual ~Lockable ()
virtual bool check (long maxwait=-1)
virtual bool unlockAll ()
virtual SemaphorelockableSemaphore ()
virtual RWLocklockableRWLock ()

Protected Member Functions

 ThreadedSource (const char *format="slin")
virtual void run ()=0
virtual void cleanup ()
bool looping (bool runConsumers=false) const
Protected Member Functions inherited from RefObject
virtual void zeroRefs ()
bool resurrect ()

Friends

class ThreadedSourcePrivate

Additional Inherited Members

Public Types inherited from DataNode
enum  DataFlags {
  DataStart = 0x0001 , DataEnd = 0x0002 , DataMark = 0x0004 , DataSilent = 0x0008 ,
  DataMissed = 0x0010 , DataError = 0x0020 , DataPrivate = 0x0100
}
Static Public Member Functions inherited from DataNode
static unsigned long invalidStamp ()
Static Public Member Functions inherited from RefObject
static bool alive (const RefObject *obj)
static bool efficientIncDec ()
Static Public Member Functions inherited from GenObject
static void * getObject (const String &name, const GenObject *obj)
static bool getObjCounting ()
static void setObjCounting (bool enable)
static NamedCountergetObjCounter (const String &name, bool create=true)
static ObjListgetObjCounters ()
Static Public Member Functions inherited from Mutex
static int count ()
static int locks ()
static bool efficientTimedLock ()
Static Public Member Functions inherited from Lockable
static void wait (unsigned long maxwait)
static unsigned long wait ()
static void startUsingNow ()
static void enableSafety (bool safe=true)
static bool safety ()
Protected Attributes inherited from DataSource
unsigned long m_nextStamp
ObjList m_consumers
Protected Attributes inherited from DataNode
DataFormat m_format
unsigned long m_timestamp

Detailed Description

Data source with own thread.

A data source with a thread of its own

Constructor & Destructor Documentation

◆ ThreadedSource()

ThreadedSource ( const char * format = "slin")
inlineexplicitprotected

Threaded Source constructor

Parameters
formatName of the data format, default "slin" (Signed Linear)

References DataSource::DataSource().

Member Function Documentation

◆ cleanup()

virtual void cleanup ( )
protectedvirtual

The cleanup after thread method, deletes the source if already dereferenced and set for asynchronous deletion

◆ destroyed()

virtual void destroyed ( )
virtual

The destruction notification, checks that the thread is gone

Reimplemented from DataSource.

◆ looping()

bool looping ( bool runConsumers = false) const
protected

Check if the calling thread should keep looping the worker method

Parameters
runConsumersTrue to keep running as long consumers are attached
Returns
True if the calling thread should remain in the run() method

◆ run()

virtual void run ( )
protectedpure virtual

The worker method. You have to reimplement it as you need

◆ running()

bool running ( ) const

Check if the data thread is running

Returns
True if the data thread was started and is running

◆ start()

bool start ( const char * name = "ThreadedSource",
Thread::Priority prio = Thread::Normal )

Starts the worker thread

Parameters
nameStatic name of this thread
prioThread's priority
Returns
True if started, false if an error occured

◆ stop()

void stop ( )

Stops and destroys the worker thread if running

◆ thread()

Thread * thread ( ) const

Return a pointer to the worker thread

Returns
Pointer to running worker thread or NULL

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