
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