Am 01.10.2012 20:35, schrieb Denis Loh:
> Hi,
>
> this sounds interesting. How do I use it? I guess, I just need to add
> this to a small header and include it everywhere it shall count it?
>
> Am 01.10.2012 20:14, schrieb ArtemGr:
>> Tommi Mäkitalo <tommi@...> writes:
>>> If you call tnt::Tntnet::shutdown, tntnet stops accepting new requests
>>> and waits until all requests are finished. There is no direct way to
>>> detect active requests.
>>>
>>> What about my suggestion to implement it in a global class? Any request,
>>> you want to monitor may instantiate a class, which increments a global
>>> (atomic) counter in the ctor and decrements it in the destructor. Then
>>> you can always check the counter.
>> Indeed, Denis could use an atomic with a RAII semantic to count open
>> requests.
>>
>> #include <atomic>
>> struct request_counter_t {
>> static std::atomic<int> OPEN_REQUESTS (0);
>> request_counter_t(){++OPEN_REQUESTS;}
>> ~request_counter_t(){--OPEN_REQUESTS;}
>> };
>>
>>
That is the solution, I suggested. In every request, you want to count
you add this:
<%cpp>
request_counter_t request_counter;
</%cpp>
That's easy. Then you have always the number of active requests in
"request_counter_t::OPEN_REQUESTS".
Tommi
------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general