Go to the source code of this file.
Classes | |
class | CbdataParent |
class | generic_cbdata |
class | CallbackData |
an old-style void* callback parameter More... | |
Macros | |
#define | cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) |
#define | CBDATA_DECL_(type, methodSpecifiers) |
declaration-generator used internally by CBDATA_CLASS() and CBDATA_CHILD() More... | |
#define | CBDATA_CLASS(type) CBDATA_DECL_(type, noexcept) |
#define | CBDATA_CHILD(type) |
#define | CBDATA_INTERMEDIATE() |
#define | CBDATA_CLASS_INIT(type) cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN |
#define | CBDATA_NAMESPACED_CLASS_INIT(namespace, type) cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN |
#define | cbdataReference(var) (cbdataInternalLock(var), var) |
#define | cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0) |
Typedefs | |
typedef int | cbdata_type |
Functions | |
void * | cbdataInternalAlloc (cbdata_type type) |
void * | cbdataInternalFree (void *p) |
void | cbdataInternalLock (const void *p) |
void | cbdataInternalUnlock (const void *p) |
int | cbdataInternalReferenceDoneValid (void **p, void **tp) |
int | cbdataReferenceValid (const void *p) |
cbdata_type | cbdataInternalAddType (cbdata_type type, const char *label, int size) |
Variables | |
static const cbdata_type | CBDATA_UNKNOWN = 0 |
Macro Definition Documentation
◆ CBDATA_CHILD
#define CBDATA_CHILD | ( | type | ) |
cbdata-enables a final CbdataParent-derived class in a hierarchy sets the class declaration section to "private" use this at the start of your class declaration for consistency sake
◆ CBDATA_CLASS
#define CBDATA_CLASS | ( | type | ) | CBDATA_DECL_(type, noexcept) |
cbdata-enables a stand-alone class that is not a CbdataParent child sets the class declaration section to "private" use this at the start of your class declaration for consistency sake
◆ CBDATA_CLASS_INIT
#define CBDATA_CLASS_INIT | ( | type | ) | cbdata_type type::CBDATA_##type = CBDATA_UNKNOWN |
Creates a global instance pointer for the CBDATA memory allocator to allocate and free objects for the matching CBDATA_CLASS().
Place this in the appropriate .cc file for the class being registered.
May be placed inside an explicit namespace scope declaration, or CBDATA_NAMESPACED_CLASS_INIT() used instead.
◆ CBDATA_DECL_
#define CBDATA_DECL_ | ( | type, | |
methodSpecifiers | |||
) |
◆ CBDATA_INTERMEDIATE
#define CBDATA_INTERMEDIATE | ( | ) |
cbdata-enables a non-final CbdataParent-derived class T in a hierarchy. Using this macro is required to be able to create cbdata pointers in T constructors, when the current vtable is still pointing to T::toCbdata() that would have been pure without this macro, leading to FATAL runtime OnTerminate() calls. However, assuming that the final cbdata pointer will still point to T::this is risky – multiple inheritance changes "this"!
sets the class declaration section to "private" use this at the start of your class declaration for consistency sake
◆ CBDATA_NAMESPACED_CLASS_INIT
#define CBDATA_NAMESPACED_CLASS_INIT | ( | namespace, | |
type | |||
) | cbdata_type namespace::type::CBDATA_##type = CBDATA_UNKNOWN |
Creates a global instance pointer for the CBDATA memory allocator to allocate and free objects for the matching CBDATA_CLASS().
Place this in the appropriate .cc file for the class being registered.
◆ cbdataReference
#define cbdataReference | ( | var | ) | (cbdataInternalLock(var), var) |
Creates a new reference to a cbdata entry. Used when you need to store a reference in another structure. The reference can later be verified for validity by cbdataReferenceValid().
- Deprecated:
- Prefer the use of CbcPointer<> smart pointer.
- Parameters
-
var The reference variable is a pointer to the entry, in all aspects identical to the original pointer. But semantically it is quite different. It is best if the reference is thought of and handled as a "void *".
◆ cbdataReferenceDone
#define cbdataReferenceDone | ( | var | ) | do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0) |
Removes a reference created by cbdataReference().
- Deprecated:
- Prefer the use of CbcPointer<> smart pointer.
- Parameters
-
var The reference variable. Will be automatically cleared to nullptr
◆ cbdataReferenceValidDone
#define cbdataReferenceValidDone | ( | var, | |
ptr | |||
) | cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) |
Typedef Documentation
◆ cbdata_type
typedef int cbdata_type |
cbdata types. Similar to the MEM_* types, but managed in cbdata.cc A big difference is that cbdata types are dynamically allocated.
Initially only UNKNOWN type is predefined. Other types are added at runtime by CBDATA_CLASS().
Function Documentation
◆ cbdataInternalAddType()
cbdata_type cbdataInternalAddType | ( | cbdata_type | type, |
const char * | label, | ||
int | size | ||
) |
Create a run-time registration for the class type with cbdata memory allocator.
- Note
- For internal CBDATA use only.
Definition at line 117 of file cbdata.cc.
References assert, cbdata_index, cbdata_types, memPoolCreate, CBDataIndex::pool, size, xmalloc, and xrealloc().
◆ cbdataInternalAlloc()
void * cbdataInternalAlloc | ( | cbdata_type | type | ) |
Allocates a new entry of a registered CBDATA type.
- Note
- For internal CBDATA use only.
Definition at line 145 of file cbdata.cc.
References Mem::Allocator::alloc(), assert, cbdata_htable, cbdata_index, cbdata_types, cbdataCount, cbdata::cookie, cbdata::Cookie, cbdata::data, debugs, cbdata::locks, CBDataIndex::pool, cbdata::type, and cbdata::valid.
◆ cbdataInternalFree()
void * cbdataInternalFree | ( | void * | p | ) |
Frees a entry allocated by cbdataInternalAlloc().
Once this has been called cbdataReferenceValid() and cbdataReferenceValidDone() will return false regardless of whether there are remaining cbdata references.
cbdataReferenceDone() must still be called for any active references to the cbdata entry. The cbdata entry will be freed only when the last reference is removed.
- Note
- For internal CBDATA use only.
Definition at line 203 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, and cbdata::FromUserData().
◆ cbdataInternalLock()
void cbdataInternalLock | ( | const void * | p | ) |
Definition at line 221 of file cbdata.cc.
References assert, debugs, cbdata::FromUserData(), and INT_MAX.
Referenced by logfile_mod_daemon_open().
◆ cbdataInternalReferenceDoneValid()
int cbdataInternalReferenceDoneValid | ( | void ** | p, |
void ** | tp | ||
) |
Removes a reference created by cbdataReference() and checks it for validity. Meant to be used on the last dereference, usually to make a callback.
- Parameters
-
var The reference variable. Will be automatically cleared to nullptr ptr A temporary pointer to the referenced data (if valid).
Definition at line 282 of file cbdata.cc.
References cbdataInternalUnlock(), and cbdataReferenceValid().
◆ cbdataInternalUnlock()
void cbdataInternalUnlock | ( | const void * | p | ) |
Definition at line 238 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, and cbdata::FromUserData().
Referenced by cbdataInternalReferenceDoneValid(), and logfile_mod_daemon_close().
◆ cbdataReferenceValid()
int cbdataReferenceValid | ( | const void * | p | ) |
- Parameters
-
p A cbdata entry reference pointer.
- Return values
-
0 A reference is stale. The pointer refers to a entry already freed. true The reference is valid and active.
Definition at line 265 of file cbdata.cc.
References assert, debugs, and cbdata::FromUserData().
Referenced by CbcPointer< Cbc >::CbcPointer(), ConnStateData::borrowPinnedConnection(), ACLChecklist::calcImplicitAnswer(), ACLChecklist::callerGone(), AsyncJob::callException(), AsyncJob::callStart(), StoreIOStateCb::canDial(), EventDialer::canDial(), CommCbFunPtrCallT< Dialer >::canFire(), cbdataInternalReferenceDoneValid(), EventScheduler::checkEvents(), Helper::Session::checkForTimedOutRequests(), clientGetMoreData(), clientSocketDetach(), clientSocketRecipient(), clientStreamDetach(), ACLFilledChecklist::conn(), diskHandleRead(), downloaderRecipient(), EventScheduler::dump(), esiBufferRecipient(), esiProcessStream(), esiStreamDetach(), esiStreamRead(), esiStreamStatus(), externalAclHandleReply(), ACLChecklist::fastCheck(), ftpSendReply(), CbcPointer< Cbc >::get(), ClientHttpRequest::getConn(), Comm::Connection::getPeer(), DiskdIOStrategy::handle(), helperDispatch(), helperHandleRead(), helperReturnBuffer(), helperStatefulDispatch(), helperStatefulHandleRead(), ClientRequestContext::httpStateIsValid(), idnsCallbackOneWithAnswer(), ConnStateData::isOpen(), TunnelStateData::keepGoingAfterRead(), ClientHttpRequest::noteAdaptationAnswer(), CbcPointer< Cbc >::operator=(), peerCountMcastPeersAbort(), peerDigestFetchedEnough(), peerDigestHandleReply(), ACLChecklist::prepNonBlocking(), TunnelStateData::ReadClient(), TunnelStateData::ReadServer(), clientReplyContext::sendMoreData(), SslBumpEstablish(), tunnelStartShoveling(), CallbackData::valid(), PeerPoolMgr::validPeer(), TunnelStateData::writeClientDone(), TunnelStateData::WriteClientDone(), TunnelStateData::writeServerDone(), and TunnelStateData::WriteServerDone().
Variable Documentation
◆ CBDATA_UNKNOWN
|
static |