1 #ifndef NETCACHE__SRV_INLINES__HPP
2 #define NETCACHE__SRV_INLINES__HPP
74 clock_gettime(CLOCK_REALTIME, &
result);
124 if (tv_sec <
t.tv_sec)
126 else if (tv_sec >
t.tv_sec)
128 else if (tv_nsec <
t.tv_nsec)
130 else if (tv_nsec >
t.tv_nsec)
139 tv_nsec +=
t.tv_nsec;
151 if (tv_nsec >=
t.tv_nsec) {
152 tv_nsec -=
t.tv_nsec;
157 tv_nsec -=
t.tv_nsec;
406 template <
typename NumType>
446 template <
typename NumType>
Class used in all diagnostic logging.
const CSrvDiagMsg & operator<<(CTempString str) const
Converts input value to string and adds to started log message.
CSrvDiagMsg & PrintParam(CTempString name, CTempString value)
Adds parameter to "request-start" or "extra" message.
Task controlling a socket.
Uint2 m_WrPos
Position of current writing pointer in the write buffer.
bool IsProxyInProgress(void)
Check whether proxying started earlier is still in progress.
bool NeedToClose(void)
Checks if socket should be closed because of long inactivity or because server is in "hard" shutdown ...
void x_CloseSocket(bool do_abort)
Close or abort the socket – they have little difference, thus they joined in one method.
CSrvSocketTask * m_ProxySrc
Source task for proxying.
bool HasError(void)
Checks if socket has some error in it.
void AbortSocket(void)
Abort the socket, i.e.
CSrvSocketTask & WriteText(CTempString message)
Write text into socket.
CSrvSocketTask & WriteNumber(NumType num)
Write number into socket as string, i.e.
bool IsReadDataAvailable(void)
Checks if there's some data available for reading in internal buffers.
void CloseSocket(void)
Close the socket gracefully, i.e.
bool ProxyHadError(void)
Check whether proxying started earlier finished successfully or any of sockets had some error in it.
bool m_NeedToFlush
Flag showing that task needs to flush all write buffers.
bool m_NeedToClose
Flag showing that socket needs to be closed because of long inactivity.
char * m_RdBuf
Read buffer.
bool CanHaveMoreRead(void)
Checks if socket can ever have more data to read even though it may not have it at the moment.
bool m_ProxyHadError
Flag showing that last proxying operation finished with error.
bool m_SockCanReadMore
Flag showing that socket can have more reads, i.e. there was no EOF yet.
bool m_FlushIsDone
Flag showing that write buffers were flushed.
bool m_RegError
Flag showing if there's error pending on the socket.
bool ReadData(void *buf, Uint2 size)
Read from socket exactly the given data size.
CSrvSocketTask * m_ProxyDst
Destination task for proxying.
bool ReadToBuf(void)
Read from socket into internal buffer.
void RequestFlush(void)
Request flushing of all data saved in internal write buffers to socket.
Uint2 m_RdPos
Position of current reading in the read buffer, i.e.
bool ReadNumber(NumType *num)
Read from socket a number in native machine representation.
void WriteData(const void *buf, size_t size)
Write the exact amount of data into the socket.
bool IsWriteDataPending(void)
Checks if there's some data pending in write buffers and waiting to be sent to kernel.
Uint2 m_WrSize
Size of data in the write buffer waiting for writing.
Uint2 m_RdSize
Size of data available for reading in the read buffer.
bool NeedEarlyClose(void)
Checks if socket should be closed because of internal reasons (long inactivity or "hard" shutdown as ...
void x_PrintError(void)
Prints socket's error if there's any error pending on the socket.
CSrvSocketTask & WriteBool(bool b)
bool FlushIsDone(void)
Check if data flushing requested earlier is complete.
CRequestContext * GetDiagCtx(void)
Get current diagnostic context for the task.
CRequestContext * m_DiagCtx
Current diagnostic context for this task.
void SetPriority(Uint4 prty)
Set and retrieve task's priority.
void SetRunnable(bool boost=false)
Set this task "runnable", i.e.
Uint4 m_Priority
Task's priority.
Class incorporating convenient methods to work with struct timespec.
bool operator>(const CSrvTime &t) const
Compare object's value to another CSrvTime object's value.
int Compare(const CSrvTime &t) const
Compares object's value to another CSrvTime object's value.
bool operator<(const CSrvTime &t) const
static int CurSecs(void)
Current time in seconds since epoch (time_t).
bool operator>=(const CSrvTime &t) const
CSrvTime & operator-=(const CSrvTime &t)
Subtract value of other CSrvTime object from this one.
time_t & Sec(void)
Read/set number of seconds since epoch stored in the object.
CSrvTime & operator+=(const CSrvTime &t)
Add value of other CSrvTime object to this one.
bool operator<=(const CSrvTime &t) const
static CSrvTime Current(void)
Exact current time with precision up to nanoseconds.
Uint8 AsUSec(void) const
Converts object's value to microseconds since epoch.
long & NSec(void)
Read/set number of nanoseconds stored in the object.
bool IsTransFinished(void)
Check if transition completeness was consumed.
bool m_TransFinished
Flag showing that transition was already consumed.
bool IsTransStateFinal(void)
Checks if "Final" state was already reached.
ETransState m_TransState
Current state of the task.
static TSrvThreadNum GetMaxRunningThreads(void)
Returns maximum number of worker threads allowed ([task_server]/max_threads parameter in ini-file).
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 bool IsInShutdown(void)
Checks if TaskServer received request to shutdown.
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...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
The NCBI C++ standard methods for dealing with std::string.
static const char * str(char *buf, int n)
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint16_t Uint2
2-byte (16-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const char * data(void) const
Return a pointer to the array represented.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
size_type size(void) const
Return the length of the represented array.
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
bool IsServerStopping(void)
TSrvThreadNum s_MaxRunningThreads
#define ACCESS_ONCE(x)
Purpose of this macro is to force compiler to access variable exactly at the place it's written (no m...
Uint2 TSrvThreadNum
Type for thread number in TaskServer.