I just found out about ArrayPool existence, but it's documentation is somewhat lacking.
I'd like to know if Rent(.) and Return(.) are thread-safe.
Edit: looks like I didn't notice the "Thread Safety" part of documentation; but reading some of the comments and answers I was relieved I wasn't the only one that didn't.
Thread SafetyThis class is thread-safe. All members may be used by multiple threads concurrently.
In common application models, only one thread at a time executes user code, which minimizes the need for thread safety. For this reason, the . NET class libraries are not thread safe by default.
ArrayPool<T> vs. Memory pools are used to reuse existing memory blocks; you can use them to allocate memory blocks dynamically. Array pools manage a pool of arrays and rent them when asked for.
Thread safety is the technique which manipulates shared data structure in a manner that guarantees the safe execution of a piece of code by the multiple threads at the same time. A code is called thread-safe. If it is run concurrently without break function.
it's documentation is somewhat lacking.
You can read about thread safety under Thread Safety:
Thread Safety
This class is thread-safe. All members may be used by multiple threads concurrently.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With