On Fri, Feb 21, 2003 at 02:13:12AM +0100, Alfredo Braunstein wrote:
> 2) I've changed bucket_ to a pointer, so to reduce the swapping time to one
> operation (which is indeed threads-safe), because swap is defined as a
> template:
You know you can specialise this template, right ? I'm sure there must
be a cleaner solution than this ... I don't quite understand why you do
this swap anyway. What's wrong with just emptying the queue with pop()
in-place ? The locking stuff ?
I don't quite follow what context is racing with what other context.
Remember the timer is based on a GUI implementation so can't "interrupt"
any straight-line code that doesn't go back to the event loop...
> that the code is efficient (and I hope correct) but somewhat ugly. I plan
> to simplify it enormously when real threads become available. For instance,
Simplify ? threads ? Hrmmm...
Simple whitespace stuff :
std::queue<Cache::ItemPtr> * bucket_;
not
std::queue<Cache::ItemPtr> *bucket_;
while (cache_queue_.size() && counter--) {
not
while ( cache_queue_.size() && counter-- ) {
(and everywhere else)
you still have one not two newlines between some functions.
thanks,
john