1234567891011121314151617181920212223242526272829303132333435363738394041424344module juptune.core.ds.pointer;
struct SharedRefCount(
alias ValueT
)
{
/++ STRUCTS ++/
///
struct Payload
{
/++ VARIABLES ++/
///
ptrdiff_t _count;
///
ValueT _value;
}
/++ ALIASES ++/
/// Safely accesses the underlying shared value.
alias access = ;
/// ditto.
alias accessGC = ;
/// Instantiates this SharedRefCount, using the provided init function to setup the underlying value.
alias make = ;
/// ditto.
alias makeGC = ;
/++ FUNCTIONS ++/
///
Result accessImpl(DelegateT)(DelegateT func);
/// Returns: Whether this SharedRefCount has a value or not.
bool isNull();
///
Result makeImpl(DelegateT)(DelegateT initFunc);
/++ VARIABLES ++/
///
shared shared Payload* _payload;
}
A shared ref counted pointer.
Memory management is only handled by stdc's calloc & friends.
Because I don't want to complicate things too much right now, ValueTmust be a zero-init type.
| Name | Description |
|---|---|
| access |
Safely accesses the underlying shared value. |
| accessGC |
ditto. |
| make |
Instantiates this SharedRefCount, using the provided init function to setup the underlying value. |
| makeGC |
ditto. |
| Name | Description |
|---|---|
| accessImpl | |
| isNull |
Returns: Whether this SharedRefCount has a value or not. |
| makeImpl |
| Name | Description |
|---|---|
| Payload |
| Name | Description |
|---|---|
| _payload |