From: Bill Wade (bill.wade_at_[hidden])
Date: 2000-09-01 08:27:34


> From: William Kempf [mailto:sirwillard_at_[hidden]]

> However, I still think we're just splitting hairs. Even though it
> may result in an extra lock, exchange() can be used to perform
> get/set. For performance reasons, yes, I can see adding get/set to
> my list, but I don't think we're talking about removing anything
> here. Or are we?

Back to the list I think we're talking about:

typedef ... atomic_t;
long increment(atomic_t& dest);
long decrement(atomic_t& dest);
long add(atomic_t& dest, long value);
long add(atomic_t& dest, const atomic_t& value);
long exchange(atomic_t& dest, long value);
long exchange(long& value, const atomic_t& value);
long compare_exchange(atomic_t& dest, long compare, long value);

I do think you should include
  long get(atomic_t& dest);
  void set(atomic_t& dest, long value);
which can be implemented in terms of the other functions, but may be
significantly faster in their "pure" form.

I would remove the second exchange. It looks like a verbose get() to me.

I think the "small" atomic class should provide no more than
  get,set,increment,decrement,exchange
with inc/decrement returning either zero-ness and/or sign of the result. I
think somebody said that some platforms only return zero-ness. This class
should be widely implementable.

A "larger" class can additionally provide compare_exchange and the first
add, but should not have an is-a relationship with the smaller class.

I don't know a fast way to implement the second add (which seems to need two
locks) on any Win32 platform.