13
edits
(Revise based on bug #427109 comments #19 and #26) |
(Add thread safety note, add temporary notification disabling.) |
||
Line 39: | Line 39: | ||
* minimum. The callee should try to free memory in order | * minimum. The callee should try to free memory in order | ||
* to restore the reserve. | * to restore the reserve. | ||
* | |||
* The allocator will repeatedly deliver condition | |||
* notifications until the condition desists or all callback | |||
* functions have disabled RESERVE_CND_LOW notifications for | |||
* the event that caused the current condition. | |||
* | * | ||
* RESERVE_CND_CRIT: The reserve was not large enough to satisfy a pending | * RESERVE_CND_CRIT: The reserve was not large enough to satisfy a pending | ||
* allocation request. | * allocation request. Some callee must free adequate | ||
* in order to prevent application failure. | * memory in order to prevent application failure (unless | ||
* the condition spontaneously desists due to concurrent | |||
* deallocation). | |||
* | |||
* The allocator will repeatedly deliver condition | |||
* notifications until the condition desists or all callback | |||
* functions have disabled RESERVE_CND_CRIT notifications | |||
* for the event that caused the current condition. | |||
* | * | ||
* RESERVE_CND_FAIL: An allocation request could not be satisfied, despite all | * RESERVE_CND_FAIL: An allocation request could not be satisfied, despite all | ||
Line 66: | Line 78: | ||
* callbacks are likely to result (which places extra burden on the application | * callbacks are likely to result (which places extra burden on the application | ||
* to avoid deadlocking). | * to avoid deadlocking). | ||
* | |||
* Callback functions must be thread-safe, since it is possible that multiple | |||
* threads will call into the same callback function concurrently. | |||
*/ | */ | ||
Line 86: | Line 101: | ||
* | * | ||
* Output: | * Output: | ||
* ret: If false, | * ret: If false, the allocator will cease re-notification for the specific | ||
* | * event that caused the current condition. If true, the allocator may | ||
* re-notify the callback of the specific event that caused the current | |||
* condition. | |||
*/ | */ | ||
typedef bool reserve_cb_t(void *ctx, reserve_cnd_t cnd, size_t size); | typedef bool reserve_cb_t(void *ctx, reserve_cnd_t cnd, size_t size); | ||
Line 182: | Line 199: | ||
* condition. | * condition. | ||
*/ | */ | ||
bool reserve_min_set(size_t min); | bool reserve_min_set(size_t min);</pre> | ||
</pre> | |||
== Implementation (non-)details == | == Implementation (non-)details == |
edits