Add force_unlock() to allocator_storage. #195
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature is almost never needed. However, when it is needed, it is badly needed.
Consider the case where a program forks. The allowable operations in the child (before calling exec) are very limited. However, we might want to use a special purpose allocator. But, if that allocator can be used my multiple threads, then it is possible that one of those threads is holding the lock when fork is called. This means that the child can't acquire the lock because the thread holding it will never get to run and release the lock within the child process.
In this case, the child must be able to unlock the allocator.
This is, admittedly, a very exceptional use case. However, it has been added in such a way that it will only appear in the API if the provided Mutex type supports
force_unlock
, which is unlikely for most use cases.The only other way of accomplishing this task is using nasty techniques to subvert the visibility access rules of the language since the mutex is one of multiple a private base classes.
Another small change to support this feature was to add a member access through pointer operator to the mutex storage classes.