A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
interlocked.read is for reading a 64 bit integer with a 32 bit app.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am looking at source code of OwinHttpListener. I particularly want to understand two things
Why updating of CanAcceptMoreRequests variable is using Interlocked but not the read in both ProcessRequestsAsync as well as in OffloadStartNextRequest methods.
In the OffloadStartNextRequest method is spinning a new thread when the condition _listener.IsListening && CanAcceptMoreRequests is successful and calling ProcessRequestsAsync which has a while loop on the same condition. In ProcessRequestsAsync method, it waits for HTTP request and before processing request it is again calling OffloadStartNextRequest which in turn calls ProcessRequestsAsync method again in a new thread and potentially same chain happens as more requests comes in quickly. Does it not flood with threads executing same code with while loop
What am I missing?
A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
interlocked.read is for reading a 64 bit integer with a 32 bit app.
Thanks. I am aware of increment/decrement.. Question was mostly for read.. So you say that interlocked.read is only for long and not required for int
In regards to second question, i found the answer myself with a test application and that part is clear to me
if using integers, you do not need to lock the read, only the write. the interlocked method calls a low level hardware command that implements a safe increment and decrement.
the interlocked counters are used to limit the thread creation.