winss
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
winss::SvScanTmpl< TService, TMutex, TProcess > Class Template Reference

The svscan template. More...

#include <svscan.hpp>

Collaboration diagram for winss::SvScanTmpl< TService, TMutex, TProcess >:
Collaboration graph
[legend]

Public Member Functions

 SvScanTmpl (winss::NotOwningPtr< winss::WaitMultiplexer > multiplexer, const fs::path &scan_dir, DWORD rescan, bool signals, winss::EventWrapper close_event)
 SvScan constructor. More...
 
 SvScanTmpl (const SvScanTmpl &)=delete
 No copy. More...
 
 SvScanTmpl (SvScanTmpl &&)=delete
 No move. More...
 
virtual void Scan (bool timeout)
 Does a scan of the scan directory. More...
 
virtual void CloseAllServices (bool ignore_flagged)
 Closes all the services. More...
 
virtual void Exit (bool close_services)
 Signals the scanner to exit. More...
 
SvScanTmploperator= (const SvScanTmpl &)=delete
 No copy. More...
 
SvScanTmploperator= (SvScanTmpl &&)=delete
 No move. More...
 

Static Public Attributes

static const int kMutexTaken = 100
 Scan dir in use error. More...
 
static const int kFatalExitCode = 111
 Something went wrong. More...
 
static constexpr const char kMutexName [7] = "svscan"
 Mutex name. More...
 
static constexpr const char kTimeoutGroup [7] = "svscan"
 The timeout group for the multiplexer. More...
 
static constexpr const char kSvscanDir [14] = ".winss-svscan"
 The directory for svscan data. More...
 
static constexpr const char kFinishFile [7] = "finish"
 Finish file. More...
 
static constexpr const char kSigTermFile [8] = "SIGTERM"
 SIGTERM file. More...
 
static constexpr const char kEnvDir [18] = ".winss-svscan\\env"
 Env directory. More...
 

Protected Member Functions

void Init ()
 Initializes svscan. More...
 
void Check (const fs::path &service_dir)
 Checks the given service directory. More...
 
void Schedule ()
 Schedules the next scan of the scan directory. More...
 
void Terminate ()
 Handles a signal to terminate. More...
 
void Stop ()
 Stops the svscan instance. More...
 

Static Protected Member Functions

static void ReadEnv ()
 Reads the env directory into the current environment. More...
 

Protected Attributes

winss::NotOwningPtr< winss::WaitMultiplexermultiplexer
 The event multiplexer for svscan. More...
 
fs::path scan_dir
 The scan directory. More...
 
const DWORD rescan
 The directory scan period. More...
 
TMutex mutex
 The svscan global mutex. More...
 
bool exiting = false
 Exiting flag. More...
 
bool close_on_exit = true
 Option to close services on exit. More...
 
bool signals = false
 Use handlers for signals. More...
 
winss::EventWrapper close_event
 Event when to stop. More...
 
std::vector< TService > services
 A list of services. More...
 

Detailed Description

template<typename TService, typename TMutex, typename TProcess>
class winss::SvScanTmpl< TService, TMutex, TProcess >

The svscan template.

Scans a directory either on a timer or on demand and starts supervisors for each service directory it sees.

Template Parameters
TServiceThe service implementation type.
TMutexThe mutex implementation type.
TMutexThe process implementation type.

Constructor & Destructor Documentation

template<typename TService , typename TMutex , typename TProcess >
winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl ( winss::NotOwningPtr< winss::WaitMultiplexer multiplexer,
const fs::path &  scan_dir,
DWORD  rescan,
bool  signals,
winss::EventWrapper  close_event 
)
inline
template<typename TService , typename TMutex , typename TProcess >
winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl ( const SvScanTmpl< TService, TMutex, TProcess > &  )
delete

No copy.

template<typename TService , typename TMutex , typename TProcess >
winss::SvScanTmpl< TService, TMutex, TProcess >::SvScanTmpl ( SvScanTmpl< TService, TMutex, TProcess > &&  )
delete

No move.

Member Function Documentation

template<typename TService , typename TMutex , typename TProcess >
void winss::SvScanTmpl< TService, TMutex, TProcess >::Check ( const fs::path &  service_dir)
inlineprotected

Checks the given service directory.

If the service dir has not been seen then it will be added to the list. If the service dir has been seen it will be checked to make sure it is running.

Parameters
[in]service_dirThe service directory.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().

template<typename TService , typename TMutex , typename TProcess >
virtual void winss::SvScanTmpl< TService, TMutex, TProcess >::CloseAllServices ( bool  ignore_flagged)
inlinevirtual

Closes all the services.

Parameters
ignore_flaggedForce the services to close.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Stop().

template<typename TService , typename TMutex , typename TProcess >
virtual void winss::SvScanTmpl< TService, TMutex, TProcess >::Exit ( bool  close_services)
inlinevirtual

Signals the scanner to exit.

Parameters
close_servicesMark if the services should be closed.

References winss::SvScanTmpl< TService, TMutex, TProcess >::operator=(), and winss::WaitMultiplexer::Stop().

template<typename TService , typename TMutex , typename TProcess >
void winss::SvScanTmpl< TService, TMutex, TProcess >::Init ( )
inlineprotected
template<typename TService , typename TMutex , typename TProcess >
SvScanTmpl& winss::SvScanTmpl< TService, TMutex, TProcess >::operator= ( const SvScanTmpl< TService, TMutex, TProcess > &  )
delete
template<typename TService , typename TMutex , typename TProcess >
SvScanTmpl& winss::SvScanTmpl< TService, TMutex, TProcess >::operator= ( SvScanTmpl< TService, TMutex, TProcess > &&  )
delete

No move.

template<typename TService , typename TMutex , typename TProcess >
static void winss::SvScanTmpl< TService, TMutex, TProcess >::ReadEnv ( )
inlinestaticprotected

Reads the env directory into the current environment.

References winss::SvScanTmpl< TService, TMutex, TProcess >::kEnvDir, and WINDOWS.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().

template<typename TService , typename TMutex , typename TProcess >
virtual void winss::SvScanTmpl< TService, TMutex, TProcess >::Scan ( bool  timeout)
inlinevirtual
template<typename TService , typename TMutex , typename TProcess >
void winss::SvScanTmpl< TService, TMutex, TProcess >::Schedule ( )
inlineprotected
template<typename TService , typename TMutex , typename TProcess >
void winss::SvScanTmpl< TService, TMutex, TProcess >::Stop ( )
inlineprotected
template<typename TService , typename TMutex , typename TProcess >
void winss::SvScanTmpl< TService, TMutex, TProcess >::Terminate ( )
inlineprotected

Member Data Documentation

template<typename TService , typename TMutex , typename TProcess >
winss::EventWrapper winss::SvScanTmpl< TService, TMutex, TProcess >::close_event
protected

Event when to stop.

template<typename TService , typename TMutex , typename TProcess >
bool winss::SvScanTmpl< TService, TMutex, TProcess >::close_on_exit = true
protected

Option to close services on exit.

template<typename TService , typename TMutex , typename TProcess >
bool winss::SvScanTmpl< TService, TMutex, TProcess >::exiting = false
protected
template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kEnvDir[18] = ".winss-svscan\\env"
static
template<typename TService , typename TMutex , typename TProcess >
const int winss::SvScanTmpl< TService, TMutex, TProcess >::kFatalExitCode = 111
static

Something went wrong.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().

template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kFinishFile[7] = "finish"
static
template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kMutexName[7] = "svscan"
static

Mutex name.

template<typename TService , typename TMutex , typename TProcess >
const int winss::SvScanTmpl< TService, TMutex, TProcess >::kMutexTaken = 100
static

Scan dir in use error.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Init().

template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kSigTermFile[8] = "SIGTERM"
static
template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kSvscanDir[14] = ".winss-svscan"
static
template<typename TService , typename TMutex , typename TProcess >
constexpr const char winss::SvScanTmpl< TService, TMutex, TProcess >::kTimeoutGroup[7] = "svscan"
static
template<typename TService , typename TMutex , typename TProcess >
winss::NotOwningPtr<winss::WaitMultiplexer> winss::SvScanTmpl< TService, TMutex, TProcess >::multiplexer
protected

The event multiplexer for svscan.

template<typename TService , typename TMutex , typename TProcess >
TMutex winss::SvScanTmpl< TService, TMutex, TProcess >::mutex
protected

The svscan global mutex.

template<typename TService , typename TMutex , typename TProcess >
const DWORD winss::SvScanTmpl< TService, TMutex, TProcess >::rescan
protected

The directory scan period.

template<typename TService , typename TMutex , typename TProcess >
fs::path winss::SvScanTmpl< TService, TMutex, TProcess >::scan_dir
protected

The scan directory.

Referenced by winss::SvScanTmpl< TService, TMutex, TProcess >::Scan().

template<typename TService , typename TMutex , typename TProcess >
std::vector<TService> winss::SvScanTmpl< TService, TMutex, TProcess >::services
protected

A list of services.

template<typename TService , typename TMutex , typename TProcess >
bool winss::SvScanTmpl< TService, TMutex, TProcess >::signals = false
protected

Use handlers for signals.


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