Signal: rename Signal to Signal_mt and Signal_st to Signal.

The single-threaded version is fine for most of the use cases we're planning
on, and is half the size on most platforms.
This commit is contained in:
Peter Johnson
2018-06-29 22:09:36 -07:00
parent c8afe9bc2f
commit 70960b0251
2 changed files with 7 additions and 8 deletions

View File

@@ -806,11 +806,10 @@ private:
/**
* Specialization of SignalBase to be used in single threaded contexts.
* Slot connection, disconnection and signal emission are not thread-safe.
* The performance improvement over the thread-safe variant is not impressive,
* so this is not very useful.
* This is significantly smaller than the thread-safe variant.
*/
template <typename... T>
using Signal_st = SignalBase<detail::NullMutex, T...>;
using Signal = SignalBase<detail::NullMutex, T...>;
/**
* Specialization of SignalBase to be used in multi-threaded contexts.
@@ -822,7 +821,7 @@ using Signal_st = SignalBase<detail::NullMutex, T...>;
* instead for that use case.
*/
template <typename... T>
using Signal = SignalBase<mutex, T...>;
using Signal_mt = SignalBase<mutex, T...>;
/**
* Specialization of SignalBase to be used in multi-threaded contexts, allowing

View File

@@ -50,11 +50,11 @@ std::atomic<int> sum{0};
void f(int i) { sum += i; }
void emit_many(Signal<int>& sig) {
void emit_many(Signal_mt<int>& sig) {
for (int i = 0; i < 10000; ++i) sig(1);
}
void connect_emit(Signal<int>& sig) {
void connect_emit(Signal_mt<int>& sig) {
for (int i = 0; i < 100; ++i) {
auto s = sig.connect_scoped(f);
for (int j = 0; j < 100; ++j) sig(1);
@@ -68,7 +68,7 @@ namespace wpi {
TEST(Signal, ThreadedMix) {
sum = 0;
Signal<int> sig;
Signal_mt<int> sig;
std::array<std::thread, 10> threads;
for (auto& t : threads) t = std::thread(connect_emit, std::ref(sig));
@@ -79,7 +79,7 @@ TEST(Signal, ThreadedMix) {
TEST(Signal, ThreadedEmission) {
sum = 0;
Signal<int> sig;
Signal_mt<int> sig;
sig.connect(f);
std::array<std::thread, 10> threads;