Replace coral::callable
with coral::closure
#9
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kayomn/ona#9
Loading…
Reference in New Issue
No description provided.
Delete Branch "replace-callable"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Deprecates and removes
coral::callable
for handling type erasure of functions and functors in favor ofcoral::closure
.As mentioned in #7, this has a number of benefits.
Memory layout drops from 32 to 16 bytes on x86-64 and 8 bytes under 32-bit compilation.
No more redundant copying of bits before they are executed.
Reduced copying and less L-values will give the compiler an easier time optimizing out the pointer indirections.
The new preferred mechanism for creating functors that
coral::closure
will accept is to pass a direct R-value to the function so that the potential for memory corruption is reduced. For most use cases, this has - and will continue to be - the standard when using functions with closures.To remain compatible with the previous functor erasure semantics, a compatibility constructor is supplied that accepts a functor pointer. This still modifies the callsite slightly, however the risk of not making value-to-pointer semantics explicit far outweighed the value of accepting and L-value reference without warning.
Closes #7.