|
The Pedigree Project 0.1
|
#include <SharedPointer.h>
Collaboration diagram for SharedPointer< T >:Classes | |
| struct | Control |
Public Member Functions | |
| SharedPointer () | |
| SharedPointer (T *ptr) | |
| SharedPointer (SharedPointer< T > &&other) noexcept | |
| virtual | ~SharedPointer () |
| SharedPointer (const SharedPointer< T > &p) | |
| void | reset () |
| void | reset (T *ptr) |
| T * | get () const |
| T * | operator-> () const |
| T & | operator* () const |
| SharedPointer< T > & | operator= (const SharedPointer< T > &p) |
| SharedPointer< T > & | operator= (SharedPointer< T > &&p) noexcept |
| operator bool () const | |
| bool | unique () const |
| size_t | refcount () const |
| bool | operator== (const SharedPointer &p) const |
| bool | operator!= (const SharedPointer &p) const |
| bool | operator< (const SharedPointer &p) const |
| bool | operator<= (const SharedPointer &p) const |
| bool | operator> (const SharedPointer &p) const |
| bool | operator>= (const SharedPointer &p) const |
Static Public Member Functions | |
| template<class... Args> | |
| static SharedPointer< T > | allocate (Args...) |
| template<class... Args> | |
| static SharedPointer< T > | tryAllocate (Args...) |
| static SharedPointer< T > | tryAdopt (T *ptr) |
Private Member Functions | |
| void | release () noexcept |
Private Attributes | |
| struct SharedPointer::Control * | m_Control |
Provides a reference-counted pointer that can be freely shared, and is automatically destroyed when the last owner's instance is destructed.
Definition at line 31 of file SharedPointer.h.
| SharedPointer< T >::SharedPointer | ( | ) |
Default instantiation, without an associated pointer object.
Definition at line 152 of file SharedPointer.h.
| SharedPointer< T >::SharedPointer | ( | T * | ptr | ) |
Instantiate, owning the given memory region.
Definition at line 155 of file SharedPointer.h.
References SharedPointer< T >::reset().
|
noexcept |
Move into the given SharedPointer object (no refcount increase). When moving out of a SharedPointer, the previous instance becomes invalid and must be re-initialized.
Definition at line 160 of file SharedPointer.h.
|
virtual |
Destruction, which automatically frees the pointer if no owners remain.
Definition at line 167 of file SharedPointer.h.
| SharedPointer< T >::SharedPointer | ( | const SharedPointer< T > & | p | ) |
Create another reference to the given SharedPointer.
Definition at line 172 of file SharedPointer.h.
|
static |
Creates a SharedPointer with a default allocation.
Definition at line 264 of file SharedPointer.h.
References SharedPointer< T >::reset().
Referenced by SymbolTable::getOrInsertTree().
Here is the caller graph for this function:| T * SharedPointer< T >::get | ( | ) | const |
Retrieve the internal pointer, or null if no object is held.
Definition at line 197 of file SharedPointer.h.
Referenced by PosixSubsystem::addFileDescriptor(), ProcFs::addProcess(), Process::beginTermination(), MemoryMapManager::clone(), PosixSubsystem::closeFileDescriptor(), EpollInstance::control(), UnixSocketSyscalls::create(), PosixSubsystem::descriptorMatchesOpenDescription(), PosixSubsystem::duplicateFileDescriptor(), PosixSubsystem::freeFd(), UnixSocketSyscalls::listen(), SharedPointer< T >::operator==(), UnixSocketSyscalls::pairWith(), UnixSocketSyscalls::queryReady(), PosixSubsystem::queueSignalDelivery(), UnixSocketSyscalls::readinessGenerations(), and ReadinessSource::subscribeReadiness().
Here is the caller graph for this function:
|
explicit |
Whether or not this pointer is valid.
Definition at line 245 of file SharedPointer.h.
| bool SharedPointer< T >::operator!= | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 321 of file SharedPointer.h.
| T & SharedPointer< T >::operator* | ( | ) | const |
Dereference the internal pointer (dangerous if no object held).
Definition at line 210 of file SharedPointer.h.
| T * SharedPointer< T >::operator-> | ( | ) | const |
Dereference the internal pointer (null if no object is held).
Definition at line 205 of file SharedPointer.h.
| bool SharedPointer< T >::operator< | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 326 of file SharedPointer.h.
| bool SharedPointer< T >::operator<= | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 331 of file SharedPointer.h.
| SharedPointer< T > & SharedPointer< T >::operator= | ( | const SharedPointer< T > & | p | ) |
Release any currently held object, and then reference that held by the given SharedPointer.
Definition at line 215 of file SharedPointer.h.
|
noexcept |
Move the other SharedPointer instance into this one.
Definition at line 236 of file SharedPointer.h.
| bool SharedPointer< T >::operator== | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 316 of file SharedPointer.h.
References SharedPointer< T >::get().
| bool SharedPointer< T >::operator> | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 336 of file SharedPointer.h.
| bool SharedPointer< T >::operator>= | ( | const SharedPointer< T > & | p | ) | const |
Definition at line 341 of file SharedPointer.h.
| size_t SharedPointer< T >::refcount | ( | ) | const |
Indicates this SharedPointer's current reference count.
Definition at line 255 of file SharedPointer.h.
|
privatenoexcept |
Internal do-er to release a reference to the held object.
Definition at line 297 of file SharedPointer.h.
| void SharedPointer< T >::reset | ( | ) |
Reset this SharedPointer, reducing the refcount on any held object.
Definition at line 179 of file SharedPointer.h.
Referenced by PosixSubsystem::addFileDescriptor(), SharedPointer< T >::allocate(), Thread::cleanStateLevel(), PosixSubsystem::closeFileDescriptor(), SocketRights::create(), PosixSubsystem::duplicateFileDescriptor(), FileDescriptor::FileDescriptor(), PosixSubsystem::freeFd(), UnixSocket::receiveDatagram(), SharedPointer< T >::SharedPointer(), and SharedPointer< T >::tryAllocate().
Here is the caller graph for this function:| void SharedPointer< T >::reset | ( | T * | ptr | ) |
Reset this SharedPointer, reducing the refcount on any held object, and then set this SharedPointer to track the given memory.
Definition at line 184 of file SharedPointer.h.
|
static |
Takes ownership, deleting ptr if its control allocation fails.
Definition at line 286 of file SharedPointer.h.
Referenced by Process::setCtty().
Here is the caller graph for this function:
|
static |
Returns empty if the kernel allocator cannot provide either allocation.
Definition at line 272 of file SharedPointer.h.
References SharedPointer< T >::reset().
Referenced by Process::addThread(), and VFS::syncFilesystem().
Here is the caller graph for this function:| bool SharedPointer< T >::unique | ( | ) | const |
Indicates whether this SharedPointer is only held by one owner.
Definition at line 250 of file SharedPointer.h.