#include <corelib/ncbidiag.hpp>
#include <corelib/request_ctx.hpp>
#include <corelib/ncbistr.hpp>
#include <corelib/ncbitime.hpp>
#include <corelib/ncbimtx.hpp>
#include <corelib/ncbithr.hpp>
Include dependency graph for nc_utils.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| class | CQuickStrStream |
| Stream-like class to accumulate all in one string without actual streams-related overhead. More... | |
| class | CPrintTextProxy |
| Stream-like class to help unify printing some text messages to diagnostics and to any iostream. More... | |
| class | CNCStatFigure< T > |
| Class representing one statistical value. More... | |
| class | CNCBGThread< Functor > |
| Thread running background task. More... | |
| class | CNCMethodWrap< Executor > |
| Special wrapper for object's method that can be used as functor, e.g. More... | |
| class | CNCBitMaskBase< num_elems > |
| Base class for bit masks of any size. More... | |
| class | CNCBitMaskBase< 1 > |
| Optimized specialization of bit mask that fits entirely in 1 element of type TNCBitMaskElem. More... | |
| class | CNCBitMaskBase< 2 > |
| Optimized specialization of bit mask that fits entirely in 2 elements of type TNCBitMaskElem. More... | |
| class | CNCBitMask< num_bits > |
| Class for working with bit masks containing given number of bits. More... | |
| class | CNCTlsObject< Derived, ObjType > |
| Base class for the object specific for each thread. More... | |
| struct | SNCFastMutex |
| Special equivalent of SSystemFastMutex that exposes necessary method to public. More... | |
Defines | |
| #define | NCTlsGet pthread_getspecific |
| #define | NCTlsSet pthread_setspecific |
| #define | NCTlsFree pthread_key_delete |
| #define | NCTlsCreate(key, destr) pthread_key_create(&key, destr) |
| Special define for creation of the TLS key. | |
Typedefs | |
| typedef size_t | TNCBitMaskElem |
| Type to use for bit masks. | |
| typedef pthread_key_t | TNCTlsKey |
| Synonyms for TLS-related functions on different platforms. | |
| typedef unsigned int | TNCThreadIndex |
| Type for index of the current thread. | |
Functions | |
| CNcbiOstream & | operator<< (CNcbiOstream &stream, const CQuickStrStream &str) |
| Additional overloaded operator to allow automatic transformation of CQuickStrStream to string when outputting to any standard stream. | |
| template<class Functor> | |
| CNCBGThread< Functor > * | NewBGThread (Functor functor) |
| Convenient function creating new background thread for given functor. | |
| template<class Executor> | |
| CNCBGThread< CNCMethodWrap< Executor > > * | NewBGThread (Executor *executor, void(Executor::*method)(void)) |
| Convenient function creating new background thread for given executor object and given method in it. | |
| void | g_InitNCThreadIndexes (void) |
| Initialize system that will acquire thread indexes for each thread. | |
| TNCThreadIndex | g_GetNCThreadIndex (void) |
| Get index of the current thread. | |
| template<class TLeft, class TRight> | |
| TLeft | g_SafeDiv (TLeft left, TRight right) |
| Utility function to safely do division even if divisor is 0. | |
| unsigned int | g_GetLogBase2 (size_t value) |
| Get integer part of the logarithm with base 2. | |
| unsigned int | g_GetLeastSetBit (size_t value) |
| Get number of least bit set. | |
| unsigned int | g_GetBitsCnt (size_t value) |
| Get number of bits set. | |
Variables | |
| static const unsigned int | kNCMaxThreadsCnt = 25 |
| Maximum number of threads when NetCache will most effectively avoid contention between threads for some internal data structures. | |
| static const unsigned int | kNCMaskElemSize = SIZEOF_SIZE_T * 8 |
| Number of bits in one element of type TNCBitMaskElem. | |
|
|
Special define for creation of the TLS key. Parameter 'key' must be a variable. Definition at line 377 of file nc_utils.hpp. Referenced by g_InitNCThreadIndexes(), and CNCTlsObject< Derived, ObjType >::Initialize(). |
|
|
Definition at line 374 of file nc_utils.hpp. Referenced by CNCTlsObject< Derived, ObjType >::Finalize(). |
|
|
Definition at line 372 of file nc_utils.hpp. Referenced by g_GetNCThreadIndex(), and CNCTlsObject< Derived, ObjType >::GetObjPtr(). |
|
|
Definition at line 373 of file nc_utils.hpp. Referenced by g_GetNCThreadIndex(), and CNCTlsObject< Derived, ObjType >::GetObjPtr(). |
|
|
Type to use for bit masks.
Definition at line 254 of file nc_utils.hpp. |
|
|
Type for index of the current thread.
Definition at line 382 of file nc_utils.hpp. |
|
|
Synonyms for TLS-related functions on different platforms.
Definition at line 371 of file nc_utils.hpp. |
|
|
Get number of bits set. Implementation uses minimum number of operations without using additional variables or memory. Trick was taken from http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel. Definition at line 508 of file nc_utils.hpp. Referenced by CNCBitMaskBase< 2 >::GetCntSet(), CNCBitMaskBase< 1 >::GetCntSet(), and CNCBitMaskBase< num_elems >::GetCntSet(). |
|
|
Get number of least bit set. For instance for the binary number 10010100 it will return 2. Definition at line 495 of file nc_utils.hpp. References g_GetLogBase2(). Referenced by CNCBitMaskBase< 2 >::GetClosestSet(), and CNCBitMaskBase< 1 >::GetClosestSet(). |
|
|
Get integer part of the logarithm with base 2. In other words function returns index of the greatest bit set when bits are indexed from lowest to highest starting with 0 (e.g. for binary number 10010001 it will return 7). Definition at line 462 of file nc_utils.hpp. Referenced by g_GetLeastSetBit(), and CNCDBStat::x_GetSizeIndex(). |
|
|
Get index of the current thread. All threads are indexed with incrementing numbers starting from 1. Thread is indexed only when this function is called and if it wasn't indexed yet. Definition at line 51 of file nc_utils.cpp. References CAtomicCounter::Add(), NCTlsGet, NCTlsSet, s_NCThreadIndexKey, and s_NextThreadIndex. Referenced by CNCDBStat::CreateTlsObject(), CNCMMStats_Getter::CreateTlsObject(), CNCMMChunksPool_Getter::CreateTlsObject(), CNCMMChainsPool_Getter::CreateTlsObject(), CNCMMSizePool_Getter::CreateTlsObject(), and CNCServerStat_Getter::CreateTlsObject(). |
|
|
Initialize system that will acquire thread indexes for each thread. This function must be called before g_GetNCThreadIndex() is used. Definition at line 44 of file nc_utils.cpp. References NCTlsCreate, s_NCThreadIndexKey, s_NextThreadIndex, and CAtomicCounter::Set(). |
|
||||||||||||||||
|
Utility function to safely do division even if divisor is 0.
Definition at line 452 of file nc_utils.hpp. |
|
||||||||||||||||
|
Convenient function creating new background thread for given executor object and given method in it. Convenience is in automatic instantiation based on parameter value so that you don't need to state template parameters for CNCBGThread and CNCMethodWrap. Definition at line 801 of file nc_utils.hpp. |
|
||||||||||
|
Convenient function creating new background thread for given functor. Convenience is in automatic instantiation based on parameter value so that you don't need to state template parameter for CNCBGThread. Definition at line 794 of file nc_utils.hpp. Referenced by CNCFileSystem::Initialize(), and CNCMMCentral::RunLateInit(). |
|
||||||||||||
|
Additional overloaded operator to allow automatic transformation of CQuickStrStream to string when outputting to any standard stream.
Definition at line 640 of file nc_utils.hpp. |
|
|
Number of bits in one element of type TNCBitMaskElem.
Definition at line 256 of file nc_utils.hpp. |
|
|
Maximum number of threads when NetCache will most effectively avoid contention between threads for some internal data structures. This constant was made different from kNCMMMaxThreadsCnt (though with similar meaning) because in memory manager changing in number of threads can result in pretty significant change in memory consumption when in all other parts of NetCache it's not so significant. So this constant is much more flexible for changes than kNCMMMaxThreadsCnt. Definition at line 53 of file nc_utils.hpp. Referenced by CNCServerStat_Getter::CreateTlsObject(), CNCDBStat::CreateTlsObject(), CNCServerStat::Print(), and CNCDBStat::Print(). |
1.4.6
Modified on Wed Dec 09 08:18:32 2009 by modify_doxy.py rev. 173732