Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test std::any performance #53

Draft
wants to merge 68 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
5d505d9
Test std::any performance
MarcusTomlinson Aug 11, 2023
7dfde3d
Update fast_any
MarcusTomlinson Aug 11, 2023
ee8fde9
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 11, 2023
7f32447
Update fast_any
MarcusTomlinson Aug 11, 2023
60b6752
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 11, 2023
b71ddb6
Update fast_any
MarcusTomlinson Aug 11, 2023
3952cb0
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 11, 2023
54ac24f
Update fast_any
MarcusTomlinson Aug 11, 2023
d77584e
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 11, 2023
852ef06
Fix crash in tests
MarcusTomlinson Aug 11, 2023
6d7cd4c
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 11, 2023
2bcf79a
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
54882e2
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
f8b8298
Clean up SignalBus docs
MarcusTomlinson Aug 12, 2023
b833789
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
54f9798
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
bc0d004
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
0e8269b
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
fb7d6ee
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
78def21
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 12, 2023
c2994fe
Update fast_any
MarcusTomlinson Aug 13, 2023
c89e36a
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 13, 2023
f344ee4
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 14, 2023
358f754
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 19, 2023
53884e6
Run just the TenThousandComponents test
MarcusTomlinson Aug 19, 2023
eebc584
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 19, 2023
40747ca
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 24, 2023
9f8653b
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 25, 2023
bc32af0
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 25, 2023
f7f4c4a
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 26, 2023
071c14f
Clean up Component.cpp
MarcusTomlinson Aug 27, 2023
6a5cc3e
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 27, 2023
dc91f4e
Merge master
MarcusTomlinson Aug 27, 2023
4c9c037
Merge branch 'master' into std_any-test
MarcusTomlinson Sep 3, 2023
0afbf60
Merge branch 'master' into std_any-test
MarcusTomlinson Sep 3, 2023
51b92ed
Merge branch 'master' into std_any-test
MarcusTomlinson Sep 4, 2023
c27e8ea
Merge branch 'master' into std_any-test
MarcusTomlinson Sep 4, 2023
d9b245f
Merge branch 'master' into std_any-test
MarcusTomlinson Sep 11, 2023
c47f0b4
Fix build
MarcusTomlinson Sep 11, 2023
e66003b
Uncomment tests
MarcusTomlinson Sep 12, 2023
ccf92fd
Merge branch 'master' into std_any-test
MarcusTomlinson Nov 20, 2023
81aace4
Merge branch 'master' into std_any-test
MarcusTomlinson Dec 17, 2023
7a6fff5
Merge branch 'master' into std_any-test
MarcusTomlinson Dec 31, 2023
7131dec
Merge branch 'master' into std_any-test
MarcusTomlinson Jan 1, 2024
ed1021e
Merge branch 'master' into std_any-test
MarcusTomlinson Jan 25, 2024
f4ae376
Merge branch 'master' into std_any-test
MarcusTomlinson Feb 17, 2024
7ac5ec0
Merge branch 'master' into std_any-test
MarcusTomlinson Feb 24, 2024
dbd3888
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 14, 2024
6e6e1fb
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 14, 2024
d6808cb
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 15, 2024
53fd427
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 15, 2024
a088b53
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 17, 2024
f78b139
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 17, 2024
f7cb71b
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 18, 2024
5d45481
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 18, 2024
75d1cf8
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 21, 2024
ef59044
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 28, 2024
4950de2
Fix build
MarcusTomlinson Mar 28, 2024
09527fc
11.1.3
MarcusTomlinson Mar 30, 2024
df42e82
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 30, 2024
73afcfc
Merge branch 'master' into std_any-test
MarcusTomlinson Mar 30, 2024
f3be19f
Revert tasks.json
MarcusTomlinson Mar 30, 2024
6dce14f
Merge branch 'master' into std_any-test
MarcusTomlinson Apr 5, 2024
d508d52
Merge branch 'master' into std_any-test
MarcusTomlinson Aug 21, 2024
e21ba06
Merge branch 'master' into std_any-test
MarcusTomlinson Nov 15, 2024
4ffd570
Merge branch 'master' into std_any-test
MarcusTomlinson Nov 15, 2024
0e43e03
Merge branch 'master' into std_any-test
MarcusTomlinson Nov 15, 2024
f4e98ec
Merge branch 'master' into std_any-test
MarcusTomlinson Nov 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions include/dspatch/SignalBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#pragma once

#include "../fast_any/any.h"

#include <any>
#include <vector>

namespace DSPatch
Expand Down Expand Up @@ -62,7 +61,7 @@ class SignalBus final
void SetSignalCount( int signalCount );
int GetSignalCount() const;

fast_any::any* GetSignal( int signalIndex );
std::any* GetSignal( int signalIndex );

bool HasValue( int signalIndex ) const;

Expand All @@ -75,16 +74,16 @@ class SignalBus final
template <typename ValueType>
void MoveValue( int signalIndex, ValueType&& newValue );

void SetSignal( int toSignalIndex, const fast_any::any& fromSignal );
void MoveSignal( int toSignalIndex, fast_any::any& fromSignal );
void SetSignal( int toSignalIndex, const std::any& fromSignal );
void MoveSignal( int toSignalIndex, std::any& fromSignal );

void ClearValue( int signalIndex );
void ClearAllValues();

fast_any::type_info GetType( int signalIndex ) const;
const std::type_info& GetType( int signalIndex ) const;

private:
std::vector<fast_any::any> _signals;
std::vector<std::any> _signals;
};

inline SignalBus::SignalBus() = default;
Expand All @@ -106,7 +105,7 @@ inline int SignalBus::GetSignalCount() const
return (int)_signals.size();
}

inline fast_any::any* SignalBus::GetSignal( int signalIndex )
inline std::any* SignalBus::GetSignal( int signalIndex )
{
// You might be thinking: Why the raw pointer return here?

Expand All @@ -131,7 +130,14 @@ inline ValueType* SignalBus::GetValue( int signalIndex ) const

// See: GetSignal().

return _signals[signalIndex].as<ValueType>();
try
{
return const_cast<ValueType*>( &std::any_cast<const ValueType&>( _signals[signalIndex] ) );
}
catch ( const std::exception& )
{
return nullptr;
}
}

template <typename ValueType>
Expand All @@ -146,12 +152,12 @@ inline void SignalBus::MoveValue( int signalIndex, ValueType&& newValue )
_signals[signalIndex].emplace<ValueType>( std::forward<ValueType>( newValue ) );
}

inline void SignalBus::SetSignal( int toSignalIndex, const fast_any::any& fromSignal )
inline void SignalBus::SetSignal( int toSignalIndex, const std::any& fromSignal )
{
_signals[toSignalIndex].emplace( fromSignal );
_signals[toSignalIndex] = fromSignal;
}

inline void SignalBus::MoveSignal( int toSignalIndex, fast_any::any& fromSignal )
inline void SignalBus::MoveSignal( int toSignalIndex, std::any& fromSignal )
{
// You might be thinking: Why swap and not move here?

Expand Down Expand Up @@ -179,7 +185,7 @@ inline void SignalBus::ClearAllValues()
}
}

inline fast_any::type_info SignalBus::GetType( int signalIndex ) const
inline const std::type_info& SignalBus::GetType( int signalIndex ) const
{
return _signals[signalIndex].type();
}
Expand Down