It depends on Alexandria, and outside SBCL additionally on Bordeaux-Threads.
Pileup is maintained in Git:
git clone git://github.com/nikodemus/pileup.git
will get you a local copy.
http://github.com/nikodemus/pileup
is the GitHub project page.
Class precedence list:
heap, structure-object, tA thread-safe binary heap.
Heap operations which need the heap to remain consistent heap lock it. Users can also group multiple heap operations into atomic units using
with-locked-heap.Thread-safety is implemented using a single lock per heap. While Pileup heaps are fine for threaded use, a more specialized solution is recommended when the heap is highly contested between multiple threads.
Important: Pileup heaps are not asynch-unwind safe: asynchronous interrupts causing non-local exits may leave the heap in an inconsistent state or lose data. Do not use
interrupt-threador asychronous timeouts with Pileup.All slot names in
heapare internal to thepileuppackage, so it is safe to subclass using eg.defstruct:include, as long as only the exported operations are used to accessor or modify heap state.
The
predicatedetermines the ordering of the heap. It must be a function of two arguments, returning true if the first argument should be closer to top of the heap than the second. If a predicate signals an error and causes a non-local exit from a heap operation, it may leave the heap in an inconsistent state and cause a subsequent heap operation to signal an error.If
keyis notnil, it must be a function of one argument, and is used to extract values for use bypredicatefor comparison.The
namecan be used to optionally specify a name for the heap: it affects only printing of the heap.The
sizeis the size of the storage initially reserved for the heap. Specifying size is not necessary: the heap will grow as necessary, but a reasonable estimate can improve performance by eliminating unnecessary copying by allocating sufficient storage immediately.
Executes
bodywithheaplocked. Heap operations which implicitly lock the heap are:heap-insert,heap-pop,heap-delete, andmap-heap. Allows grouping multiple heap operations into atomic units.
Insert
elttoheap. Returnselt.Locks the heap during its operation unless the current thread is already holding the heap lock via
with-locked-heap.
Removes and returns the element at the top of the
heapand a secondary value oft. Should the heap be empty, both the primary and the secondary values arenil.Locks the heap during its operation unless the current thread is already holding the heap lock via
with-locked-heap.
Returns the element at the top of the
heapwithout removing it, and a secondary value oft. Should the heap be empty, both the primary and the secondary values arenil.
Removes elements of the
heapeqltoelt. Returnstif one or more elements were found and removed,nilotherwise.If
countisnil(the default), removes all elementseqltoelt, otherwise at most the indicated number.Locks the heap during its operation unless the current thread is already holding the heap lock via
with-locked-heap.
Calls
functionfor each element in heap. Returns the heap.If
orderedis true (the default), processes the elements in heap order from top down.If
orderedis false, uses unordered traversal. Unordered traversal is faster and also works on heaps that have been corrupted by eg. the heap predicate performing a non-local exit from a heap operation.Attempts to insert or delete elements to the heap from
functionwill cause an error to be signalled.Locks the heap during its operation unless the current thread is already holding the heap lock via
with-locked-heap.
Returns the name of the heap. Heap name affects only printed representation of the heap. Can be changed using
setfunlike other heap properties.
Returns the heap key, a function one argument used to extract values for use by the heap predicate. Heap key may also be
nil, meaning heap elements are used directly by the heap predicate.
Returns the heap predicate, a function of two arguments, returning true if the first argument should be closer to te top of the heap than the second.