Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
SharedPtr.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <atomic>
#include <compare>
#include <cstdint>
#include <type_traits>
#include "Stroika/Foundation/Common/Common.h"
#include "SharedPtr.inl"

Go to the source code of this file.

Classes

class  Stroika::Foundation::Memory::enable_shared_from_this< T >
 

Namespaces

namespace  Stroika::Foundation
 
namespace  std
 STL namespace.
 

Variables

constexpr bool Stroika::Foundation::Memory::kSharedPtr_IsFasterThan_shared_ptr = false
 

Variable Documentation

◆ kSharedPtr_IsFasterThan_shared_ptr

constexpr bool Stroika::Foundation::Memory::kSharedPtr_IsFasterThan_shared_ptr = false
constexpr

Callers can always use EITHER shared_ptr or SharedPtr. But this define tells which is probably faster for the most part. Often types, users will want to define a typedef which selects the faster implementation.

Note
As of 2015-10-21, and version v2.0a109, it appears on windows/VS2k13, SharedPtr is about 30% faster, and GCC 4.9 on ubuntu its about 3% faster (not enough to be significant). This requires more testing though.
As of 2016-06-09, and version v2.0a148, it appears on windows/VS2k13, SharedPtr is about 10% faster, and GCC 5.3 on ubuntu its a wash. For now - switch so we default to shared_ptr on gcc and SharedPtr using vs2k15
As of 2016-07-09, and version v2.0a156 (after SpinLock fence/lockless blockallocation changes), it appears on windows/VS2k13, SharedPtr is still about 10% faster
As of 2017-10-13 - Stroika v2.0a217, and Visual Studio.Net 2017 (15.4.0) - SharedPtr<> remains about 15% faster than shared_ptr<> on windows.
As of 2021-02-14 - Stroika v2.1b10 and Visual Studio.Net 2019 (16.8.5) - SharedPtr<> remains about 18% faster than shared_ptr<> and UNIX / g++ still too close to call - so stick with shared_ptr<>
As of 2021-11-03, Stroika v2.1b14, I switched this to always false. I was testing with shared_ptr<T> (new T ()), as opposed to make_shared<T> (), and that is obviously unfairly biased. Using make_shared, the stl::shared_ptr is clearly faster, even on VS2k.

//

Definition at line 292 of file SharedPtr.h.