Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is System.ServiceModel.Channels.BufferManager thread-safe?

I create a buffer manager through static member of BufferManager.CreateBufferManager. This new created BufferManager is used by multiple threads.

Should I use a lock with TakeBuffer() and ReturnBuffer() or it is thread-safe by design ?

like image 597
Xaqron Avatar asked Apr 17 '11 23:04

Xaqron


1 Answers

Internally BufferManager.CreateBufferManager returns an instance of WrappingBufferManager which employs no form of concurrency control, but wraps multiple instances of SynchronizedPool<T> which employ internal locking when Take()ing a new buffer. So judging by the simplicity of the WrappingBufferManager, it's safe to assume that any locking on your part would be redundant, and the returned class is in actual fact thread safe.

like image 140
Josh Avatar answered Oct 24 '22 00:10

Josh