1 #ifndef NETCACHE__TASK_SERVER__HPP
2 #define NETCACHE__TASK_SERVER__HPP
36 namespace intr = boost::intrusive;
64 struct SSrvRCUList_tag;
105 intr::cache_last<true>,
110 struct SSrvShutdownList_tag;
111 typedef intr::slist_member_hook<intr::tag<SSrvShutdownList_tag> >
TSrvSDListHook;
142 intr::constant_time_size<false>,
169 static bool Initialize(
int& argc,
const char** argv);
186 static void Run(
void);
Class to derive from to use RCU mechanism.
CSrvRCUUser(const CSrvRCUUser &)
CSrvRCUUser & operator=(const CSrvRCUUser &)
void CallRCU(void)
Method to be called to schedule call of ExecuteRCU() at appropriate time.
virtual ~CSrvRCUUser(void)
TSrvRCUListHook m_RCUListHook
virtual void ExecuteRCU(void)=0
Method implementing RCU job that was scheduled earlier by CallRCU().
Interface for an object wishing to be notified when server is going to shutdown.
TSrvSDListHook m_SDListHook
CSrvShutdownCallback(void)
virtual bool ReadyForShutdown(void)=0
Method called if server is ready to shutdown.
virtual ~CSrvShutdownCallback(void)
Factory that creates CSrvSocketTask-derived object for each connection coming to listening port which...
Task controlling a socket.
Class incorporating convenient methods to work with struct timespec.
Main class representing TaskServer infrastructure.
static const CNcbiRegistry & GetConfRegistry(void)
Obtains reference to registry read from application's ini-file.
static TSrvThreadNum GetMaxRunningThreads(void)
Returns maximum number of worker threads allowed ([task_server]/max_threads parameter in ini-file).
CTaskServer(const CTaskServer &)
static CNcbiRegistry & SetConfRegistry(void)
Used to modify original registry (to reflect RECONF modifications)
static const string & GetHostName(void)
Returns name of server this application is executing on.
static void RequestShutdown(ESrvShutdownType shutdown_type)
Asks server to start shutdown procedures.
static string GetHostByIP(Uint4 ip)
Converts 4-byte encoded IP address into server name.
static bool AddListeningPort(Uint2 port, CSrvSocketFactory *factory)
Adds port for TaskServer to listen to.
static bool ReadConfiguration(CNcbiRegistry *®)
Load (re-read) configuration from current conf file into another registry It is used in RECONF comman...
static void AddShutdownCallback(CSrvShutdownCallback *callback)
Adds new object wishing to receive callbacks when server is going to shutdown and wishing to influenc...
static TSrvThreadNum GetCurThreadNum(void)
Returns number of current worker thread. Number is 0-based.
static CSrvTime GetStartTime(void)
Returns time when this server application was started (when Initialize() method was called).
static bool IsRunning(void)
Checks if TaskServer is running now, i.e.
static void Finalize(void)
Finalizes TaskServer infrastructure.
static bool ReConfig(const CNcbiRegistry &new_reg, string &err_message)
static string IPToString(Uint4 ip)
Converts 4-byte encoded IP address into its string representation.
static void WriteSetup(CSrvSocketTask &task)
static bool IsInShutdown(void)
Checks if TaskServer received request to shutdown.
static Uint4 GetIPByHost(const string &host)
Converts server name (or IP address written as string) to encoded 4-byte IP address.
static bool Initialize(int &argc, const char **argv)
Initializes TaskServer infrastructure from given command line arguments.
static bool IsInSoftShutdown(void)
Checks if TaskServer currently is in "soft" shutdown phase when client-related operations still can p...
static bool IsInHardShutdown(void)
Checks if TaskServer currently is in "hard" shutdown phase when no operation is allowed to proceed un...
static void Run(void)
Run all TaskServer machinery.
uint8_t Uint1
1-byte (8-bit) unsigned integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
intr::member_hook< CSrvRCUUser, TSrvRCUListHook, &CSrvRCUUser::m_RCUListHook > TSrvRCUListOpt
Uint2 TSrvThreadNum
Type for thread number in TaskServer.
intr::slist_member_hook< intr::tag< SSrvRCUList_tag > > TSrvRCUListHook
intr::member_hook< CSrvShutdownCallback, TSrvSDListHook, &CSrvShutdownCallback::m_SDListHook > TSDListHookOpt
intr::slist< CSrvRCUUser, TSrvRCUListOpt, intr::cache_last< true >, intr::constant_time_size< true > > TSrvRCUList
intr::slist_member_hook< intr::tag< SSrvShutdownList_tag > > TSrvSDListHook
ESrvTaskFlags
Type for flags in CSrvTask.
ESrvShutdownType
Types of server shutdown procedures that one can request from CTaskServer.
intr::slist< CSrvShutdownCallback, TSDListHookOpt, intr::constant_time_size< false >, intr::cache_last< false > > TShutdownList