summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llapr.h2
-rw-r--r--indra/llcorehttp/_refcounted.h52
-rw-r--r--indra/llcorehttp/bufferarray.cpp6
3 files changed, 22 insertions, 38 deletions
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index af33ce666f..034546c3f3 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -168,7 +168,7 @@ public:
void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); }
void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); }
Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++
- Type operator --(int) { return apr_atomic_dec32(&mData); } // Type--
+ Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise)
private:
apr_uint32_t mData;
diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h
index 72cef6b342..a96c65fb6b 100644
--- a/indra/llcorehttp/_refcounted.h
+++ b/indra/llcorehttp/_refcounted.h
@@ -28,9 +28,11 @@
#define LLCOREINT__REFCOUNTED_H_
+#include "linden_common.h"
+
#include <boost/thread.hpp>
-#include "linden_common.h"
+#include "llapr.h"
namespace LLCoreInt
@@ -44,7 +46,7 @@ private:
void operator=(const RefCounted &); // Not defined
public:
- explicit RefCounted(bool const implicit)
+ explicit RefCounted(bool const implicit)
: mRefCount(implicit)
{}
@@ -52,42 +54,34 @@ public:
void addRef() const;
void release() const;
bool isLastRef() const;
- int getRefCount() const;
+ S32 getRefCount() const;
void noRef() const;
- static const int NOT_REF_COUNTED = -1;
+ static const S32 NOT_REF_COUNTED = -1;
protected:
virtual ~RefCounted();
virtual void destroySelf();
private:
- mutable int mRefCount;
- mutable boost::mutex mRefLock;
+ mutable LLAtomicS32 mRefCount;
}; // end class RefCounted
inline void RefCounted::addRef() const
{
- boost::mutex::scoped_lock lock(mRefLock);
- llassert_always(mRefCount >= 0);
- ++mRefCount;
+ S32 count(mRefCount++);
+ llassert_always(count >= 0);
}
inline void RefCounted::release() const
{
- int count(0);
- {
- // CRITICAL SECTION
- boost::mutex::scoped_lock lock(mRefLock);
- llassert_always(mRefCount != NOT_REF_COUNTED);
- llassert_always(mRefCount > 0);
- count = --mRefCount;
- // CRITICAL SECTION
- }
-
+ S32 count(mRefCount);
+ llassert_always(count != NOT_REF_COUNTED);
+ llassert_always(count > 0);
+ count = mRefCount--;
// clean ourselves up if that was the last reference
if (0 == count)
@@ -99,32 +93,22 @@ inline void RefCounted::release() const
inline bool RefCounted::isLastRef() const
{
- int count(0);
- {
- // CRITICAL SECTION
- boost::mutex::scoped_lock lock(mRefLock);
-
- llassert_always(mRefCount != NOT_REF_COUNTED);
- llassert_always(mRefCount >= 1);
- count = mRefCount;
- // CRITICAL SECTION
- }
-
+ const S32 count(mRefCount);
+ llassert_always(count != NOT_REF_COUNTED);
+ llassert_always(count >= 1);
return (1 == count);
}
-inline int RefCounted::getRefCount() const
+inline S32 RefCounted::getRefCount() const
{
- boost::mutex::scoped_lock lock(mRefLock);
- const int result(mRefCount);
+ const S32 result(mRefCount);
return result;
}
inline void RefCounted::noRef() const
{
- boost::mutex::scoped_lock lock(mRefLock);
llassert_always(mRefCount <= 1);
mRefCount = NOT_REF_COUNTED;
}
diff --git a/indra/llcorehttp/bufferarray.cpp b/indra/llcorehttp/bufferarray.cpp
index 6d5309a043..ae92057df0 100644
--- a/indra/llcorehttp/bufferarray.cpp
+++ b/indra/llcorehttp/bufferarray.cpp
@@ -175,7 +175,7 @@ size_t BufferArray::read(size_t pos, void * dst, size_t len)
if (pos >= mLen)
return 0;
size_t len_limit(mLen - pos);
- len = std::min(len, len_limit);
+ len = (std::min)(len, len_limit);
if (0 == len)
return 0;
@@ -189,7 +189,7 @@ size_t BufferArray::read(size_t pos, void * dst, size_t len)
{
Block & block(*mBlocks[block_start]);
size_t block_limit(block.mUsed - offset);
- size_t block_len(std::min(block_limit, len));
+ size_t block_len((std::min)(block_limit, len));
memcpy(c_dst, &block.mData[offset], block_len);
result += block_len;
@@ -223,7 +223,7 @@ size_t BufferArray::write(size_t pos, const void * src, size_t len)
{
Block & block(*mBlocks[block_start]);
size_t block_limit(block.mUsed - offset);
- size_t block_len(std::min(block_limit, len));
+ size_t block_len((std::min)(block_limit, len));
memcpy(&block.mData[offset], c_src, block_len);
result += block_len;