nidas
v1.2-1520
|
#include <SyncServer.h>
Public Types | |
enum | runStatus { RUN_CANCELED = -1, RUN_OK = 0, NOT_RUNNING = 1, RUN_EXCEPTION = 2 } |
Values that can be returned by run method. More... | |
enum | SchedPolicy { NU_THREAD_OTHER =SCHED_OTHER, NU_THREAD_FIFO =SCHED_FIFO, NU_THREAD_RR =SCHED_RR } |
Public Member Functions | |
SyncServer () | |
~SyncServer () | |
void | openStream () |
Open the data file input stream and read the nidas header, but do not parse the project. More... | |
void | init () throw (nidas::util::Exception) |
Call this method to parse the project, setup sample tags, preload calibrations using the time of the first sample, setup sample streams, and init the sensors. More... | |
int | run () throw (nidas::util::Exception) |
This method implements the Runnable interface for Threads, but it can also be called synchronously when run from main(). More... | |
virtual void | interrupt () |
Interrupt this thread. More... | |
void | read (bool once=false) throw (nidas::util::IOException) |
void | setSorterLengthSeconds (float sorter_secs) |
void | setRawSorterLengthSeconds (float sorter_secs) |
std::string | getXMLFileName () |
Return the current XML filename setting. More... | |
void | setXMLFileName (const std::string &name) |
void | resetAddress (nidas::util::SocketAddress *addr) |
void | addSampleClient (SampleClient *client) |
Specify a SampleClient instance to receive the sync samples instead of writing the sync samples to an output stream. More... | |
void | setDataFileNames (const std::list< std::string > &dataFileNames) |
void | setStopSignal (StopSignal *stop_signal) |
Set a callback function which will be called when the SyncServer reaches EOF on its input stream or stops on an error. More... | |
void | getTimeWindow (nidas::util::UTime *start, nidas::util::UTime *end) |
void | setTimeWindow (nidas::util::UTime start, nidas::util::UTime end) |
void | connect (SampleOutput *output) throw () |
Implementation of SampleConnectionRequester::connect(). More... | |
void | disconnect (SampleOutput *output) throw () |
Implementation of SampleConnectionRequester::disconnect(). More... | |
virtual void | start () throw (Exception) |
Start the thread running, meaning execute the run method in a separate thread. More... | |
virtual int | join () throw (Exception) |
The calling thread joins this thread, waiting until the thread finishes, which means either that the run() method returned, the thread called pthread_exit() or the thread was cancelled. More... | |
virtual void | kill (int sig) throw (Exception) |
Send a signal to this thread. More... | |
virtual void | cancel () throw (Exception) |
Cancel this thread. More... | |
virtual bool | isInterrupted () const |
Return true when this thread has been interrupted. More... | |
virtual bool | isRunning () const |
Is this thread running? More... | |
virtual bool | isJoined () const |
Has this thread been joined? More... | |
virtual bool | isDetached () const |
Is this a detached thread. More... | |
bool | isCancelEnabled () const |
Return true if the cancel state of this thread is PTHREAD_CANCEL_ENABLE. More... | |
bool | isCancelDeferred () const |
Return true if the cancel type of this thread is PTHREAD_CANCEL_DEFERRED. More... | |
const std::string & | getName () const throw () |
Return the name of this thread. More... | |
const std::string & | getFullName () throw () |
Return a name with a bunch of descriptive fields, specifying whether it is detached, the real-time priority, etc. More... | |
bool | setRealTimeRoundRobinPriority (int val) throw (Exception) |
bool | setRealTimeFIFOPriority (int val) throw (Exception) |
bool | setNonRealTimePriority () throw (Exception) |
void | setThreadScheduler (enum SchedPolicy policy, int priority) throw (Exception) |
void | blockSignal (int) |
Block a signal in this thread. More... | |
void | unblockSignal (int) |
Install a signal handler and unblock the signal. More... | |
Static Public Member Functions | |
static Thread * | currentThread () |
Return the thread object for the current thread. More... | |
static pthread_t | currentThreadId () |
static Thread * | lookupThread (pthread_t id) |
static const std::string & | currentName () |
Convenience routine to return the name for the current thread, or a string indicating that the name of the thread is unknown. More... | |
static std::string | getPolicyString (int policy) |
Convenience function to return a string for the given scheduler policy: "Non-RT", "RT:FIFO", "RT:RR" or "RT:Unknown". More... | |
static int | test (int argc, char **argv) |
a test method. More... | |
Static Public Attributes | |
static const int | DEFAULT_PORT = 30001 |
static const float | SORTER_LENGTH_SECS = 5.0 |
static const float | RAW_SORTER_LENGTH_SECS = 5.0 |
Protected Member Functions | |
void | setCancelEnabled (bool val) |
Set the cancel state for this thread - false means cancel requests are ignored. More... | |
void | setCancelDeferred (bool val) |
Set the cancel type for this thread. More... | |
pthread_t | getId () const |
void | testCancel () const |
Check if we have been cancelled. More... | |
virtual bool | amInterrupted () const |
Call testCancel, and return true when this thread has been interrupted. More... | |
Private Member Functions | |
void | initProject () |
void | initSensors (SampleInputStream &sis) |
void | stop () |
void | signalStop () |
void | handleSample (nidas::core::Sample *sample) |
SyncServer (const SyncServer &) | |
SyncServer & | operator= (const SyncServer &) |
Private Attributes | |
SamplePipeline | _pipeline |
SyncRecordGenerator | _syncGen |
RawSampleInputStream * | _inputStream |
SampleOutputStream * | _outputStream |
std::string | _xmlFileName |
std::list< std::string > | _dataFileNames |
nidas::util::auto_ptr < nidas::util::SocketAddress > | _address |
float | _sorterLengthSecs |
float | _rawSorterLengthSecs |
SampleClient * | _sampleClient |
StopSignal * | _stop_signal |
nidas::core::Sample * | _firstSample |
dsm_time_t | _startTime |
dsm_time_t | _startWindow |
dsm_time_t | _endWindow |
|
inherited |
Values that can be returned by run method.
User can define other values greater than RUN_EXCEPTION. These values are then returned by int join()
. Note that PTHREAD_CANCELLED is -1
Enumerator | |
---|---|
RUN_CANCELED | |
RUN_OK | |
NOT_RUNNING | |
RUN_EXCEPTION |
|
inherited |
SyncServer::SyncServer | ( | ) |
SyncServer::~SyncServer | ( | ) |
References _firstSample, _inputStream, _outputStream, _stop_signal, DLOG, and nidas::core::Sample::freeReference().
|
private |
|
inline |
Specify a SampleClient instance to receive the sync samples instead of writing the sync samples to an output stream.
References _sampleClient.
Referenced by nidas::dynld::raf::SyncRecordReader::SyncRecordReader().
|
protectedvirtualinherited |
Call testCancel, and return true when this thread has been interrupted.
This is protected because it should only called within the run method of the thread.
Referenced by nidas::core::SampleOutputRequestThread::run(), nidas::core::Looper::run(), nidas::dynld::isff::GOESOutput::run(), nidas::core::DSMServerStat::run(), and nidas::util::Thread::test().
|
inherited |
Block a signal in this thread.
This method is usually called before this Thread has started. If this Thread is currently running, then this method is only effective if called from this Thread, i.e. from its own run() method.
Because SIGINT, SIGTERM and SIGHUP are typically caught in the main thread, they are blocked by default in a Thread. Call unblockSignal(sig) if you want to catch them in a Thread.
References nidas::util::Thread::_blockedSignals, nidas::util::Thread::_unblockedSignals, nidas::util::Thread::currentThread(), nidas::util::Thread::isRunning(), and nidas::util::Thread::thr_add_sig().
Referenced by nidas::dynld::UDPSampleOutput::ConnectionMonitor::ConnectionMonitor(), nidas::core::ServerSocket::ConnectionThread::ConnectionThread(), nidas::core::DerivedDataReader::DerivedDataReader(), nidas::util::McSocketListener::McSocketListener(), nidas::util::McSocketMulticaster< SocketTT >::McSocketMulticaster(), nidas::core::SensorHandler::SensorHandler(), nidas::core::SensorOpener::SensorOpener(), nidas::util::Thread::test(), nidas::dynld::RawSampleService::Worker::Worker(), nidas::core::XmlRpcThread::XmlRpcThread(), and nidas::dynld::UDPSampleOutput::XMLSocketListener::XMLSocketListener().
|
virtualinherited |
Cancel this thread.
References nidas::util::Thread::_id, nidas::util::Thread::_mutex, nidas::util::Exception::errnoToString(), and nidas::util::Thread::getName().
Referenced by nidas::core::DSMService::cancel(), nidas::dynld::isff::GOESOutput::cancelThread(), nidas::core::DerivedDataReader::deleteInstance(), and nidas::core::DSMEngine::joinDataThreads().
|
virtual |
Implementation of SampleConnectionRequester::connect().
Does nothing.
Implements nidas::core::SampleConnectionRequester.
|
inlinestaticinherited |
Convenience routine to return the name for the current thread, or a string indicating that the name of the thread is unknown.
References nidas::util::Thread::currentThread(), nidas::util::Thread::getName(), and nidas::util::Thread::unknownName.
Referenced by nidas::util::Logger::msg_locked().
|
staticinherited |
Return the thread object for the current thread.
Returns null if not found.
Referenced by nidas::util::Thread::blockSignal(), nidas::util::Thread::currentName(), and nidas::util::Thread::unblockSignal().
|
staticinherited |
Referenced by nidas::core::Looper::removeClient().
|
virtual |
Implementation of SampleConnectionRequester::disconnect().
If client has disconnected, interrupt the sample loop and exit.
Implements nidas::core::SampleConnectionRequester.
References interrupt().
|
inherited |
Return a name with a bunch of descriptive fields, specifying whether it is detached, the real-time priority, etc.
References nidas::util::Thread::_fullname.
Referenced by nidas::util::Thread::pRun(), nidas::util::Thread::test(), nidas::util::Thread::thr_cleanup(), and nidas::util::Thread::thr_cleanup_delete().
|
inlineprotectedinherited |
References nidas::util::Thread::_id, and nidas::util::Thread::_mutex.
Referenced by nidas::util::Thread::isJoined(), nidas::util::Thread::join(), nidas::util::Thread::pRun(), and nidas::core::Looper::removeClient().
|
inherited |
Return the name of this thread.
References nidas::util::Thread::_name.
Referenced by nidas::core::DSMService::cancel(), nidas::util::Thread::cancel(), nidas::core::DSMService::checkSubThreads(), nidas::core::SensorHandler::PolledDSMSensor::checkTimeout(), nidas::util::Thread::currentName(), nidas::core::SensorHandler::PolledDSMSensor::handlePollEvents(), nidas::core::SampleSorter::heapDecrement(), nidas::core::DSMService::interrupt(), nidas::core::DSMService::join(), nidas::util::Thread::join(), nidas::core::SamplePipeline::join(), nidas::core::FsMountWorkerThread::run(), nidas::core::SampleSorter::run(), nidas::util::ThreadJoiner::run(), nidas::util::Thread::sigAction(), nidas::util::Thread::start(), nidas::util::Thread::test(), nidas::util::LogContext::threadName(), nidas::core::SampleSorter::~SampleSorter(), and nidas::util::Thread::~Thread().
|
staticinherited |
Convenience function to return a string for the given scheduler policy: "Non-RT", "RT:FIFO", "RT:RR" or "RT:Unknown".
References nidas::util::Thread::NU_THREAD_FIFO, nidas::util::Thread::NU_THREAD_OTHER, and nidas::util::Thread::NU_THREAD_RR.
Referenced by nidas::core::DSMSensor::getLooper(), and nidas::util::Thread::makeFullName().
void SyncServer::getTimeWindow | ( | nidas::util::UTime * | start, |
nidas::util::UTime * | end | ||
) |
References _endWindow, and _startWindow.
|
inline |
Return the current XML filename setting.
If called after calling openStream() and before setting it explicitly with setXMLFileName(), then the return value is the XML filename from the stream header.
References _xmlFileName.
|
private |
void SyncServer::init | ( | ) | ||
throw | ( | nidas::util::Exception | ||
) |
Call this method to parse the project, setup sample tags, preload calibrations using the time of the first sample, setup sample streams, and init the sensors.
It should be called before calling start() on the thread or before calling run() directly.
Between calling this method and entering run(), no samples have been processed, so the calibrations can be replaced and will take effect when processing starts.
References _address, _inputStream, _outputStream, _pipeline, _rawSorterLengthSecs, _sampleClient, _sorterLengthSecs, _startTime, _syncGen, nidas::dynld::raf::SyncRecordGenerator::addSampleClient(), nidas::core::ServerSocket::close(), nidas::dynld::raf::SyncRecordGenerator::connect(), nidas::core::SamplePipeline::connect(), nidas::core::ServerSocket::connect(), nidas::dynld::raf::SyncRecordGenerator::connectSource(), DLOG, nidas::core::SamplePipeline::getProcessedSampleSource(), nidas::dynld::raf::SyncRecordGenerator::init(), initProject(), initSensors(), openStream(), nidas::core::SamplePipeline::setProcHeapMax(), nidas::core::SamplePipeline::setProcSorterLength(), nidas::core::SamplePipeline::setRawHeapMax(), nidas::core::SamplePipeline::setRawSorterLength(), nidas::core::SamplePipeline::setRealTime(), and nidas::core::SampleOutputBase::setReconnectDelaySecs().
Referenced by main(), and nidas::dynld::raf::SyncRecordReader::SyncRecordReader().
|
private |
References _xmlFileName, DLOG, nidas::util::Process::expandEnvVars(), nidas::core::Project::getInstance(), and nidas::core::Project::setConfigName().
Referenced by init().
|
private |
References nidas::dynld::SampleInputStream::addSampleTag(), nidas::core::Project::getInstance(), nidas::core::DSMSensor::getRawSampleTag(), nidas::core::Project::getSensorIterator(), nidas::core::SensorIterator::hasNext(), nidas::core::DSMSensor::init(), and nidas::core::SensorIterator::next().
Referenced by init().
|
virtual |
Interrupt this thread.
This sets a boolean which can be tested with isInterrupted(). It is up to the run() implementation to return when interrupted. This is a "soft" request to terminate the thread.
What follows is a discussion of when to use cancel(), kill(), or interrupt() to terminate a thread.
If you can consistently check the state of isInterrupted() in the run method, and return if it is true, at a time interval which is an acceptable amount of time to wait for the thread to terminate, then using interrupt() should work well.
If the run method does I/O, then things are usually a bit more complicated.
If all I/O is guaranteed to finish quickly, which is a rare situation, or is done with a timeout, such as using select/poll with a timeout before every read/write, then one could still use interrupt() as above, and the thread will terminate within the timeout period.
If the thread does blocking I/O operations, and the I/O might block for a period of time longer than you're willing to wait for the thread to terminate, then you need to use kill(sig) or cancel().
If a signal is sent to the thread with kill(sig) while the thread is blocking on an I/O operation, the I/O will immediately return with an errno of EINTR, and one could then return from the run method, after any necessary cleanup.
However there is a possibility that the signal could be missed. In order to make sure you receive a signal, you must block it, so that any received signals are held as pending, and then atomically unblock it with pselect/ppoll/epoll_pwait before performing the I/O operation.
If you do not use I/O timeouts, or kill(sig) with pselect/ppoll/epoll_pwait, or other tricks such as writing to a pipe that is watched with select/poll in the run method, then using cancel() is the only way to guarantee that your thread will terminate in an acceptable amount of time.
All NIDAS Threads support deferred cancelation. Immediate asynchronous cancellation is not fully supported (and is very hard to get right). Deferred cancelation means that cancellation is delayed until the thread next calls a system function that is a cancellation point. At that point the thread run method will simply terminate without any return value from the system function, and then execute any cleanup methods that may have been registered with pthread_cleanup_push.
A list of cancellation points is provided in the pthreads(7) man page. Cancellation points are typically I/O operations, waits or sleeps.
This immediate thread termination can be a problem if there is a possibility that your objects could be left in a bad state, such as with a mutex locked, though it isn't generally a good practice to hold mutexes during a time-consuming I/O operation, wait or sleep.
One should check the run method to see if the state of the objects is OK if execution stops at any of the cancellation points. Note that logging a message, or writing to cerr is a cancellation point. Typically there is error/exception handling associated with an I/O operation. Ensuring the state is OK upon a cancellation is similar to preparation for a fatal I/O error that requires a return of the run method. One can use setCancelEnabled() to defer cancellation.
One can use pthread_cleanup_push and pthread_cleanup_pop to register cleanup routines that are called when a thread is cancelled if special handling is required.
Reimplemented from nidas::util::Thread.
References _pipeline, DLOG, nidas::core::SamplePipeline::interrupt(), nidas::util::Thread::interrupt(), and signalStop().
Referenced by disconnect(), and interrupt_sync_server().
|
inherited |
Return true if the cancel type of this thread is PTHREAD_CANCEL_DEFERRED.
References nidas::util::Thread::_cancel_deferred.
|
inherited |
Return true if the cancel state of this thread is PTHREAD_CANCEL_ENABLE.
References nidas::util::Thread::_cancel_enabled.
|
inlinevirtualinherited |
Is this a detached thread.
References nidas::util::Thread::_detached.
|
inlinevirtualinherited |
Return true when this thread has been interrupted.
Implements nidas::util::Runnable.
References nidas::util::Thread::_interrupted, and nidas::util::Thread::_mutex.
Referenced by nidas::core::SampleSorter::flush(), nidas::core::SampleOutputRequestThread::run(), nidas::core::StatusListener::run(), nidas::core::DerivedDataReader::run(), nidas::core::SensorOpener::run(), Sender::run(), nidas::core::DSMEngineStat::run(), nidas::core::SensorHandler::run(), nidas::core::FsMountWorkerThread::run(), ModemLineSetter::run(), ModemLineMonitor::run(), nidas::core::SampleBuffer::run(), nidas::core::SampleSorter::run(), ServerThread::run(), nidas::util::McSocketListener::run(), and stop().
|
inlinevirtualinherited |
Has this thread been joined?
References nidas::util::Thread::getId().
Referenced by nidas::core::FsMount::cancel(), nidas::core::DerivedDataReader::deleteInstance(), nidas::core::SensorHandler::join(), nidas::dynld::isff::GOESOutput::joinThread(), nidas::util::Thread::test(), nidas::core::SampleBuffer::~SampleBuffer(), nidas::core::SampleSorter::~SampleSorter(), and nidas::util::Thread::~Thread().
|
inlinevirtualinherited |
Is this thread running?
References nidas::util::Thread::_mutex, and nidas::util::Thread::_running.
Referenced by nidas::util::Thread::blockSignal(), nidas::core::DSMService::cancel(), nidas::core::FsMount::cancel(), nidas::dynld::isff::GOESOutput::cancelThread(), nidas::core::DSMService::checkSubThreads(), nidas::dynld::UDPSampleOutput::XMLSocketListener::checkWorkers(), nidas::dynld::UDPSampleOutput::close(), nidas::util::McSocket< SocketT >::close(), nidas::core::DerivedDataReader::deleteInstance(), nidas::core::DSMService::interrupt(), nidas::core::SamplePipeline::join(), nidas::dynld::isff::GOESOutput::joinThread(), nidas::core::DSMServerApp::killStatusThread(), nidas::dynld::isff::GOESOutput::killThread(), nidas::core::Looper::removeClient(), nidas::core::SensorHandler::run(), nidas::core::Looper::setupClientMaps(), nidas::util::Thread::test(), nidas::util::Thread::unblockSignal(), nidas::core::SampleBuffer::~SampleBuffer(), nidas::core::SampleSorter::~SampleSorter(), nidas::util::Thread::~Thread(), and nidas::dynld::UDPSampleOutput::~UDPSampleOutput().
|
virtualinherited |
The calling thread joins this thread, waiting until the thread finishes, which means either that the run() method returned, the thread called pthread_exit() or the thread was cancelled.
The return value is the int return value of the run method, or PTHREAD_CANCELED (-1). If the run method threw an Exception, it will be caught and then re-thrown by join.
Reimplemented in nidas::core::SensorHandler.
References nidas::util::Thread::_exception, nidas::util::Thread::_id, nidas::util::Thread::_mutex, nidas::util::Exception::errnoToString(), nidas::util::Thread::getId(), nidas::util::Thread::getName(), nidas::util::Thread::RUN_EXCEPTION, and nidas::util::Thread::RUN_OK.
Referenced by nidas::core::DSMService::checkSubThreads(), nidas::dynld::UDPSampleOutput::XMLSocketListener::checkWorkers(), nidas::dynld::UDPSampleOutput::close(), nidas::util::McSocketListener::close(), nidas::core::DerivedDataReader::deleteInstance(), nidas::dynld::UDPSampleOutput::XMLSocketListener::fireWorkers(), nidas::core::DSMService::join(), nidas::core::SensorHandler::join(), nidas::core::SamplePipeline::join(), nidas::core::DSMEngine::joinDataThreads(), nidas::dynld::isff::GOESOutput::joinThread(), nidas::core::DSMServerApp::killStatusThread(), nidas::core::DSMServerApp::killXmlRpcThread(), nidas::core::DSMEngine::killXmlRpcThread(), main(), nidas::core::Looper::removeClient(), nidas::util::ThreadJoiner::run(), nidas::core::SampleBuffer::~SampleBuffer(), nidas::core::SampleSorter::~SampleSorter(), nidas::core::ServerSocket::~ServerSocket(), and nidas::dynld::UDPSampleOutput::~UDPSampleOutput().
|
virtualinherited |
Send a signal to this thread.
References nidas::util::Exception::errnoToString().
Referenced by nidas::core::FsMount::cancel(), nidas::core::XmlRpcThread::interrupt(), nidas::core::SensorOpener::interrupt(), nidas::core::DerivedDataReader::interrupt(), nidas::core::SensorHandler::interrupt(), nidas::util::McSocketListener::interrupt(), nidas::core::DSMServerApp::killStatusThread(), nidas::dynld::isff::GOESOutput::killThread(), main(), nidas::core::SensorHandler::scheduleAdd(), nidas::core::SensorHandler::scheduleClose(), nidas::core::SensorHandler::scheduleReopen(), and nidas::core::SensorHandler::sensorIsOpen().
|
staticinherited |
Referenced by nidas::util::LogContext::threadName().
void SyncServer::openStream | ( | ) |
Open the data file input stream and read the nidas header, but do not parse the project.
References _dataFileNames, _firstSample, _inputStream, _startTime, _xmlFileName, nidas::core::FileSet::connect(), DLOG, nidas::core::SampleInputHeader::getConfigName(), nidas::core::FileSet::getFileSet(), nidas::dynld::SampleInputStream::getInputHeader(), nidas::core::Sample::getTimeTag(), nidas::util::UTime::parse(), nidas::dynld::SampleInputStream::readInputHeader(), nidas::dynld::SampleInputStream::readSample(), nidas::dynld::SampleInputStream::setMaxDsmId(), nidas::dynld::SampleInputStream::setMaxSampleLength(), nidas::dynld::SampleInputStream::setMaxSampleTime(), and nidas::dynld::SampleInputStream::setMinSampleTime().
Referenced by init().
|
private |
void SyncServer::read | ( | bool | once = false | ) | |
throw | ( | nidas::util::IOException | |||
) |
References DLOG, nidas::dynld::SampleInputStream::readSample(), and nidas::util::Exception::what().
Referenced by run().
|
inline |
References _address.
Referenced by parseRunstring().
|
virtual |
This method implements the Runnable interface for Threads, but it can also be called synchronously when run from main().
Implements nidas::util::Runnable.
References DLOG, read(), stop(), nidas::core::XMLImplementation::terminate(), and nidas::util::Exception::what().
Referenced by main().
|
protectedinherited |
Set the cancel type for this thread.
true means cancel requests are deferred until the next cancellation point. false means they occur instantly. This is protected, it should be called only from a thread's own run method. See the pthreads(7) man page for a list of the cancellation points.
Note: non-deferred canceling is difficult to get right. It has not been tested with this class, and is not recommended.
References nidas::util::Thread::_cancel_deferred.
|
protectedinherited |
Set the cancel state for this thread - false means cancel requests are ignored.
See pthread_setcancelstate. This is protected, it should be called only from a thread's own run method.
References nidas::util::Thread::_cancel_enabled.
|
inline |
References _dataFileNames.
Referenced by parseRunstring().
|
inherited |
|
inline |
References _rawSorterLengthSecs.
Referenced by parseRunstring().
|
inherited |
|
inherited |
|
inline |
References _sorterLengthSecs.
Referenced by parseRunstring().
|
inline |
Set a callback function which will be called when the SyncServer reaches EOF on its input stream or stops on an error.
Since the pipeline is flushed when the input is closed, no more sync samples will be sent after this function is called. It is called from the thread running the run() method.
References _stop_signal.
Referenced by nidas::dynld::raf::SyncRecordReader::SyncRecordReader().
|
inherited |
void SyncServer::setTimeWindow | ( | nidas::util::UTime | start, |
nidas::util::UTime | end | ||
) |
References _endWindow, _startWindow, DLOG, and nidas::util::UTime::toUsecs().
|
inline |
References _xmlFileName.
Referenced by parseRunstring().
|
private |
References _stop_signal, DLOG, and nidas::dynld::raf::StopSignal::stop().
Referenced by interrupt(), and stop().
|
virtualinherited |
Start the thread running, meaning execute the run method in a separate thread.
References nidas::util::Thread::_id, nidas::util::Thread::_interrupted, nidas::util::Thread::_mutex, nidas::util::Thread::_running, nidas::util::Thread::_thread_attr, nidas::util::Exception::errnoToString(), nidas::util::Thread::getName(), nidas::util::Thread::makeFullName(), nidas::util::Thread::NU_THREAD_FIFO, nidas::util::Thread::NU_THREAD_OTHER, nidas::util::Thread::NU_THREAD_RR, nidas::util::Thread::registerThread(), nidas::util::Thread::setThreadSchedulerNolock(), nidas::util::Thread::thr_run(), nidas::util::Thread::thr_run_detached(), and WLOG.
Referenced by nidas::util::McSocketListener::accept(), nidas::dynld::RawSampleService::connect(), nidas::core::DerivedDataReader::createInstance(), nidas::util::McSocket< SocketT >::joinMulticaster(), main(), nidas::core::DSMEngine::openSensors(), nidas::core::SamplePipeline::procinit(), nidas::core::SamplePipeline::rawinit(), nidas::util::McSocket< SocketT >::request(), nidas::core::DSMServerApp::run(), nidas::core::DSMEngine::run(), PSI::run(), nidas::core::SensorHandler::run(), nidas::core::FsMountWorkerThread::run(), nidas::dynld::UDPSampleOutput::XMLSocketListener::run(), nidas::core::Socket::ConnectionThread::run(), ServerThread::run(), nidas::core::Looper::setupClientMaps(), nidas::core::DSMServerApp::startXmlRpcThread(), and nidas::core::DSMEngine::startXmlRpcThread().
|
private |
References _inputStream, _outputStream, _pipeline, _sampleClient, _syncGen, nidas::dynld::SampleInputStream::close(), nidas::core::SampleOutputRequestThread::destroyInstance(), nidas::dynld::raf::SyncRecordGenerator::disconnect(), nidas::core::SamplePipeline::disconnect(), nidas::dynld::raf::SyncRecordGenerator::disconnectSource(), DLOG, nidas::dynld::raf::SyncRecordGenerator::flush(), nidas::core::SamplePipeline::getProcessedSampleSource(), nidas::core::SamplePipeline::interrupt(), nidas::util::Thread::isInterrupted(), nidas::core::SamplePipeline::join(), nidas::dynld::raf::SyncRecordGenerator::removeSampleClient(), and signalStop().
Referenced by run().
|
staticinherited |
a test method.
References nidas::util::Runnable::amInterrupted(), nidas::util::Thread::blockSignal(), nidas::util::Thread::getFullName(), nidas::util::Thread::getName(), nidas::util::Thread::isJoined(), nidas::util::Thread::isRunning(), nidas::util::Runnable::run(), nidas::util::Thread::Thread(), and nidas::util::Exception::what().
|
inlineprotectedinherited |
Check if we have been cancelled.
Calls pthread_testcancel. This is protected since it only checks the current thread - i.e. it must be called within the run method. Since it just calls pthread_testcancel, it is a cancellation point.
|
inherited |
Install a signal handler and unblock the signal.
The signal handler will log a message about the receipt of the signal at severity LOG_INFO using the nidas::util::Logger. Then, if the signal handler is being invoked from a registered Thread, the virtual method signalHandler() for that Thread will be called.
The signal handler is installed with the sigaction() system call, and will be the action for the given signal in all threads, including the main() thread. If other threads do not wish to take action on a given signal, they should call blockSignal(sig). Or they can define their own signalHandler() method.
After installing the signal handler, the signal is added to those that are unblocked for the thread, or if the Thread is not yet running, the signal will be unblocked in the thread once it runs.
As with blockSignal(), this method is typically called on this Thread before it has started. If this Thread has started, then the signal will only be unblocked if the method is called from this Thread, i.e. from its own run() method.
To install a signal handler, and then block the signal so that it is held as pending until it is later unblocked, typically with pselect(), or sigwaitinfo(), do:
References nidas::util::Thread::_blockedSignals, nidas::util::Thread::_unblockedSignals, nidas::util::Thread::currentThread(), nidas::util::Thread::isRunning(), and nidas::util::Thread::thr_add_sig().
Referenced by nidas::core::DerivedDataReader::DerivedDataReader(), nidas::core::FsMountWorkerThread::FsMountWorkerThread(), nidas::core::StatusListener::StatusListener(), nidas::core::StatusThread::StatusThread(), nidas::dynld::XMLConfigService::Worker::Worker(), nidas::core::XmlRpcThread::XmlRpcThread(), and nidas::dynld::UDPSampleOutput::XMLSocketListener::XMLSocketListener().
|
private |
Referenced by init(), and resetAddress().
|
private |
Referenced by openStream(), and setDataFileNames().
|
private |
Referenced by getTimeWindow(), handleSample(), and setTimeWindow().
|
private |
Referenced by openStream(), and ~SyncServer().
|
private |
Referenced by handleSample(), init(), openStream(), stop(), and ~SyncServer().
|
private |
Referenced by init(), stop(), and ~SyncServer().
|
private |
Referenced by init(), interrupt(), and stop().
|
private |
Referenced by init(), and setRawSorterLengthSeconds().
|
private |
Referenced by addSampleClient(), init(), and stop().
|
private |
Referenced by init(), and setSorterLengthSeconds().
|
private |
Referenced by init(), and openStream().
|
private |
Referenced by getTimeWindow(), handleSample(), and setTimeWindow().
|
private |
Referenced by setStopSignal(), signalStop(), and ~SyncServer().
|
private |
|
private |
Referenced by getXMLFileName(), initProject(), openStream(), and setXMLFileName().
|
static |
|
static |
|
static |