|
Squid Web Cache master
|
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() | |
| #define | CBDATA_CLASS(type) public: CBDATA_DECL_(type, noexcept) |
| #define | CBDATA_CLASS_WITH_MAKE(type) private: 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 |
| #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
| #define CBDATA_CLASS | ( | type | ) | public: 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
| #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.
| #define CBDATA_CLASS_WITH_MAKE | ( | type | ) | private: CBDATA_DECL_(type, noexcept) |
A CBDATA_CLASS() variant for classes that want to prevent accidental operator new() calls by making that operator private and forcing external users to call a Make() function instead.
| #define CBDATA_DECL_ | ( | type, | |
| methodSpecifiers | |||
| ) |
| #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
| #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.
| #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().
| 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 *". |
| #define cbdataReferenceDone | ( | var | ) | do {if (var) {cbdataInternalUnlock(var); var = nullptr;}} while(0) |
Removes a reference created by cbdataReference().
| var | The reference variable. Will be automatically cleared to nullptr |
| #define cbdataReferenceValidDone | ( | var, | |
| ptr | |||
| ) | cbdataInternalReferenceDoneValid((void **)&(var), (ptr)) |
| 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().
| cbdata_type cbdataInternalAddType | ( | cbdata_type | type, |
| const char * | label, | ||
| int | size | ||
| ) |
Create a run-time registration for the class type with cbdata memory allocator.
Definition at line 122 of file cbdata.cc.
References assert, cbdata_index, cbdata_types, memPoolCreate, CBDataIndex::pool, size, xmalloc, and xrealloc().
| void * cbdataInternalAlloc | ( | cbdata_type | type | ) |
Allocates a new entry of a registered CBDATA type.
Definition at line 150 of file cbdata.cc.
References Mem::Allocator::alloc(), assert, cbdata_index, cbdata_types, cbdataCount, CbdataTable(), cbdata::cookie, cbdata::Cookie, cbdata::data, debugs, cbdata::locks, CBDataIndex::pool, cbdata::type, and cbdata::valid.
| 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.
Definition at line 208 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, and cbdata::FromUserData().
| void cbdataInternalLock | ( | const void * | p | ) |
Definition at line 226 of file cbdata.cc.
References assert, debugs, cbdata::FromUserData(), and INT_MAX.
Referenced by logfile_mod_daemon_open().
| 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.
| var | The reference variable. Will be automatically cleared to nullptr |
| ptr | A temporary pointer to the referenced data (if valid). |
Definition at line 287 of file cbdata.cc.
References cbdataInternalUnlock(), and cbdataReferenceValid().
| void cbdataInternalUnlock | ( | const void * | p | ) |
Definition at line 243 of file cbdata.cc.
References assert, cbdataRealFree(), debugs, and cbdata::FromUserData().
Referenced by cbdataInternalReferenceDoneValid(), and logfile_mod_daemon_close().
| int cbdataReferenceValid | ( | const void * | p | ) |
| p | A cbdata entry reference pointer. |
| 0 | A reference is stale. The pointer refers to a entry already freed. |
| true | The reference is valid and active. |
Definition at line 270 of file cbdata.cc.
References assert, debugs, and cbdata::FromUserData().
Referenced by CbcPointer< Cbc >::CbcPointer(), ACLExternal::aclMatchExternal(), HttpStateData::buildRequestPrefix(), 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(), externalAclHandleReply(), ftpSendReply(), CbcPointer< Cbc >::get(), ClientHttpRequest::getConn(), Comm::Connection::getPeer(), DiskdIOStrategy::handle(), helperDispatch(), helperHandleRead(), helperReturnBuffer(), helperStatefulDispatch(), helperStatefulHandleRead(), idnsCallbackOneWithAnswer(), ConnStateData::isOpen(), TunnelStateData::keepGoingAfterRead(), CbcPointer< Cbc >::operator=(), peerCountMcastPeersAbort(), peerDigestHandleReply(), TunnelStateData::ReadClient(), TunnelStateData::ReadServer(), clientReplyContext::sendMoreData(), Comm::Connection::toGoneCachePeer(), tunnelStartShoveling(), CallbackData::valid(), PeerPoolMgr::validPeer(), TunnelStateData::writeClientDone(), TunnelStateData::WriteClientDone(), TunnelStateData::writeServerDone(), and TunnelStateData::WriteServerDone().
|
static |