SEED 0107: Pigweed Communications has been approved! Pigweed will adopt a new sockets API as its primary networking abstraction. The sockets API will be backed by a new, lightweight embedded-focused network protocol stack inspired by TCP/IP.
We would strongly prefer to use PMR and/or be very similar/compatible with PMR, but it just doesn’t work in our applications right now, e.g., PMR needs exceptions to signal failures
This proposal also adds desirable features like efficient reallocations
The generic allocator provides no formal guarantees, but proposed subclasses (semantic interfaces) can signal support for certain guarantees (ThreadSafeAllocator, InterruptSafeAllocator, etc.). In practice, these are just aliases for the generic allocator which does support those features as an implementation detail.
Properties like “thread safe” and “interrupt safe” are not mutually exclusive, but the subclasses are. What if you want both properties?
STL does this via allocator traits; probably need to think of doing something similar
These interfaces are intended to be used at the lowest level; “application” code should use the generic interfaces
Layered allocators: they sit on top of other allocators. Example: PoolAllocator manages a memory pool allocated from some other allocator. ObjectAllocator builds on this: allocates and deallocates on construction/destruction.
We’ve had requests from product teams to have a way to manage multiple memory pools with a single handle. The ChainedAllocatorPool proposes a solution. Includes fallback, example: if you have a kernel pool and a user pool, and you fail to allocate from the kernel pool, you can fall back to the user pool.
Tagged allocator: allocator includes a 32-bit integer as metadata, allowing tracking allocations. Intriguingly, pw_tokenizer could be used to granularly and precisely track the source of allocations via a macro that tags allocators with tokenized strings (function name, file and line number, etc.)
Should the allocators return spans instead of raw pointers? Having a definitive size avoids many common errors, and allocators may return a different amount of memory than requested (e.g., rounding up).
Question comes down to: should we create a familiar interface or a safe interface?
Similarly, could return something like a result type instead of a null pointer
The current proposal puts STL/new/delete integration out of scope, so it’s proposing more of a conventional C-style API
Need a section in the SEED that describes what to do if you just want to use new