summaryrefslogtreecommitdiff
path: root/cpp/include/IceUtil/Shared.h
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-02-12 04:59:12 +0000
committerMarc Laukien <marc@zeroc.com>2002-02-12 04:59:12 +0000
commite764b6d2adc5a0ef75caf1f6f406af86bd95aa1c (patch)
tree1136dc7e95fc1d36b509f50a9b87a1c04179a576 /cpp/include/IceUtil/Shared.h
parentmade some inline ops non-inline; added comments and TODOs (diff)
downloadice-e764b6d2adc5a0ef75caf1f6f406af86bd95aa1c.tar.bz2
ice-e764b6d2adc5a0ef75caf1f6f406af86bd95aa1c.tar.xz
ice-e764b6d2adc5a0ef75caf1f6f406af86bd95aa1c.zip
made some inline ops non-inline; added comments and TODOs
Diffstat (limited to 'cpp/include/IceUtil/Shared.h')
-rw-r--r--cpp/include/IceUtil/Shared.h56
1 files changed, 39 insertions, 17 deletions
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h
index c323cfbfbfc..f54df64ba59 100644
--- a/cpp/include/IceUtil/Shared.h
+++ b/cpp/include/IceUtil/Shared.h
@@ -39,25 +39,32 @@
* on us. We need to use _exactly_ the address the user gave us,
* not some alias that contains the same information.
*/
-typedef struct { volatile int counter; } ice_atomic_t;
+struct ice_atomic_t
+{
+ volatile int counter;
+};
-/**
+/*
* ice_atomic_set - set ice_atomic variable
* @v: pointer of type ice_atomic_t
* @i: required value
*
- * Atomically sets the value of @v to @i. Note that the guaranteed
+ * Atomically sets the value of @v to @i. Note that the guaranteed
* useful range of an ice_atomic_t is only 24 bits.
- */
-#define ice_atomic_set(v,i) (((v)->counter) = (i))
+ */
+// TODO: Does this really need to be a macro?t
+#define ice_atomic_set(v, i) (((v)->counter) = (i))
-/**
+/*
* ice_atomic_inc - increment ice_atomic variable
* @v: pointer of type ice_atomic_t
*
- * Atomically increments @v by 1. Note that the guaranteed
- * useful range of an ice_atomic_t is only 24 bits.
- */
+ * Atomically increments @v by 1. Note that the guaranteed useful
+ * range of an ice_atomic_t is only 24 bits.
+ *
+ * Inlined because this operation is performance critical.
+ */
+// TODO: Why static?
static inline void ice_atomic_inc(ice_atomic_t *v)
{
__asm__ __volatile__(
@@ -70,11 +77,13 @@ static inline void ice_atomic_inc(ice_atomic_t *v)
* ice_atomic_dec_and_test - decrement and test
* @v: pointer of type ice_atomic_t
*
- * Atomically decrements @v by 1 and
- * returns true if the result is 0, or false for all other
- * cases. Note that the guaranteed
- * useful range of an ice_atomic_t is only 24 bits.
- */
+ * Atomically decrements @v by 1 and returns true if the result is 0,
+ * or false for all other cases. Note that the guaranteed useful
+ * range of an ice_atomic_t is only 24 bits.
+ *
+ * Inlined because this operation is performance critical.
+ */
+// TODO: Why static?
static inline int ice_atomic_dec_and_test(ice_atomic_t *v)
{
unsigned char c;
@@ -86,10 +95,13 @@ static inline int ice_atomic_dec_and_test(ice_atomic_t *v)
}
/**
- * ice_atomic_exchange_add - same as InterlockedExchangeAdd. This didn't
- * come from atomic.h (the code was derived from similar code in
- * /usr/include/asm/rwsem.h)
+ * ice_atomic_exchange_add - same as InterlockedExchangeAdd. This
+ * didn't come from atomic.h (the code was derived from similar code
+ * in /usr/include/asm/rwsem.h)
+ *
+ * Inlined because this operation is performance critical.
*/
+// TODO: Why static?
static inline int ice_atomic_exchange_add(int i, ice_atomic_t* v)
{
int tmp = i;
@@ -121,6 +133,11 @@ static inline int ice_atomic_exchange_add(int i, ice_atomic_t* v)
namespace IceUtil
{
+//
+// TODO: Not all operations in this class are performance critical,
+// thus not all of them should be inlined.
+//
+
class SimpleShared : public noncopyable
{
public:
@@ -193,6 +210,11 @@ private:
bool _noDelete;
};
+//
+// TODO: Not all operations below are performance critical, thus not
+// all of them should be inlined.
+//
+
#ifdef ICE_USE_MUTEX_SHARED
inline