[asio] Re: Pass some parameter to io_service::run

James, it is not academic reason. I need latency 1-2us. Right now I have 15us. I cannot waste time on locks and I cannot create bottlenecks. And how about just let user pass "void *"? I know it is not type safe... maybe boost has something like type-safe variable argument list? On 11 January 2010 17:13, James Mansion <james@mansionfamily.plus.com>wrote:
Dmytro Ovdiienko wrote:
I don't understand why you would have an objection to a permanent binding with TLS
TLS looks like global variables. Global variables violate encapsulation. I suppose to support my program at least 2 years. I don't want to hate myself two years :)
I think that's quite a silly reason. So are singletons, but they are both useful. ...
or a temporary binding using a pool of parsers, since it seems that each datagram must be parsed entirely and then the parser reset for the next?
Exactly. But I don't want to create pool of the parsers. Access to the pool should be synchronized. Synchronization eats CPU times.
... but not nearly as silly as this one. Getting an item from a pool is a great candidate for a spinlock and if you're concerned you can easily segment the pool. Its a non-issue. I defy you to measure it in the context of all teh context switching and system calls you're doing.
Of course, the pool is a singleton. And that's like a global.
The right tools to get you what you want are right there - you're just choosing not to use them for academic reasons.
James
-- Dmytro Ovdiienko e-mail: dmitriy.ovdienko@gmail.com skype: dmitriy.ovdienko@gmail.com mobile: +38050-1909731 -- Dmytro Ovdiienko e-mail: dmitriy.ovdienko@gmail.com skype: dmitriy.ovdienko@gmail.com mobile: +38050-1909731
participants (1)
-
Dmytro Ovdiienko