using System;
using System.Collections.Generic;
namespace Capnp
{
///
/// Implements a segment allocation policy for Cap'n Proto building messages.
///
public interface ISegmentAllocator
{
///
/// Currently allocated segments.
///
IReadOnlyList> Segments { get; }
///
/// Attempts to allocate a memory block. The first allocation attempt is made inside the segment specified by .
/// If that segment does not provide enough space or does not exist, further actions depend on the flag.
/// If that flag is true, allocation will fail (return false). Otherwise, the allocation shall scan existing segments for the requested amount of space,
/// and create a new segment if none provides enough space.
///
/// Number of words to allocate
/// Index of preferred segment wherein the block should be allocated
/// Position of allocated memory block (undefined in case of failure)
/// Whether the segment specified by is mandatory
/// Whether allocation was successful
bool Allocate(uint nwords, uint preferredSegment, out SegmentSlice slice, bool forcePreferredSegment);
}
}