Getting number of messages in MessageBox
Sean Kelly
sean at invisibleduck.org
Tue Aug 6 14:57:39 PDT 2013
On Aug 6, 2013, at 1:27 PM, Dmitry Olshansky <dmitry.olsh at gmail.com> wrote:
> 06-Aug-2013 03:18, Marek Janukowicz пишет:
>> I'm using std.concurrency message passing and I'd like to check which thread
>> might be a bottleneck. The easiest would be check number of messages piled
>> up for each of them, but I could not find a way to do that. Is it possible?
>> Every detail about MessageBox seems to be hidden...
>>
>
> This is sadly intentional. The reasons must be due to some efficient concurrent queues not being able to produce reliable item count if at all.
>
> However this seems at odds with setMaxMailboxSize ...
The lack of a function to get the current mailbox size is mostly an oversight. It would be easy to return the same message count used by setMaxMailboxSize. This isn't an exact count, since that would be inefficient as you say, but it's a reasonable approximation. So I wouldn't use the returned message count as a pivotal part of a protocol design, for example, but it would be fine for determining whether a consumer is being overwhelmed by requests.
That said, with the possible exception of setMaxMailboxSize allowing one thread to affect the behavior of another thread's mailbox, I think the current functionality should all extend to interprocess messaging without alteration. I'm not sure that this could be done for a getMailboxSize call. Certainly not with any semblance of efficiency anyway. But perhaps it's reasonable to have some subset of functionality that only works on local threads so long as the core messaging API doesn't have such limitations.
More information about the Digitalmars-d-learn
mailing list