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 ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Internally
BufferManager.CreateBufferManagerreturns an instance ofWrappingBufferManagerwhich employs no form of concurrency control, but wraps multiple instances ofSynchronizedPool<T>which employ internal locking whenTake()ing a new buffer. So judging by the simplicity of theWrappingBufferManager, it’s safe to assume that any locking on your part would be redundant, and the returned class is in actual fact thread safe.