FastSignals: Normalize namespace to fastsignals.

This commit is contained in:
Joao Matos
2025-06-14 11:38:54 +01:00
committed by tritao
parent 052a898b91
commit 6930e0ac03
19 changed files with 40 additions and 40 deletions

View File

@@ -2,13 +2,13 @@
## Usage
* Use `is::signals::bind_weak` instead of `std::bind` to ensure that nothing happens if method called when binded object already destroyed
* Use `fastsignals::bind_weak` instead of `std::bind` to ensure that nothing happens if method called when binded object already destroyed
* Pass pointer to T class method as first argument, `shared_ptr<T>` or `weak_ptr<T>` as second argument
* Example: `bind_weak(&Document::save(), document, std::placeholders::_1)`, where `document` is a `weak_ptr<Document>` or `shared_ptr<Document>`
## Weak this idiom
The `is::signals::bind_weak(...)` function implements "weak this" idiom. This idiom helps to avoid dangling pointers and memory access wiolations in asynchronous and/or multithreaded programs.
The `fastsignals::bind_weak(...)` function implements "weak this" idiom. This idiom helps to avoid dangling pointers and memory access wiolations in asynchronous and/or multithreaded programs.
In the following example, we use weak this idiom to avoid using dangling pointer wehn calling `print()` method of the `Enityt`:
@@ -58,7 +58,7 @@ In the following example, `Entity::print()` method connected to the signal. Sign
#include <fastsignals/bind_weak.h>
#include <iostream>
using VoidSignal = is::signals::signal<void()>;
using VoidSignal = fastsignals::signal<void()>;
using VoidSlot = VoidSignal::slot_type;
struct Entity : std::enable_shared_from_this<Entity>
@@ -67,8 +67,8 @@ struct Entity : std::enable_shared_from_this<Entity>
VoidSlot get_print_slot()
{
// Here is::signals::bind_weak() used instead of std::bind.
return is::signals::bind_weak(&Entity::print, weak_from_this());
// Here fastsignals::bind_weak() used instead of std::bind.
return fastsignals::bind_weak(&Entity::print, weak_from_this());
}
void print()

View File

@@ -120,7 +120,7 @@ FastSignals uses another approach: `bind_weak` function:
#include <fastsignals/bind_weak.h>
#include <iostream>
using VoidSignal = is::signals::signal<void()>;
using VoidSignal = fastsignals::signal<void()>;
using VoidSlot = VoidSignal::slot_type;
struct Entity : std::enable_shared_from_this<Entity>
@@ -129,8 +129,8 @@ struct Entity : std::enable_shared_from_this<Entity>
VoidSlot get_print_slot()
{
// Here is::signals::bind_weak() used instead of std::bind.
return is::signals::bind_weak(&Entity::print, weak_from_this());
// Here fastsignals::bind_weak() used instead of std::bind.
return fastsignals::bind_weak(&Entity::print, weak_from_this());
}
void print()

View File

@@ -11,7 +11,7 @@
// 17
#include "libfastsignals/signal.h"
using namespace is::signals;
using namespace fastsignals;
int main()
{
@@ -37,7 +37,7 @@ int main()
// 17
#include "libfastsignals/signal.h"
using namespace is::signals;
using namespace fastsignals;
int main()
{

View File

@@ -1,6 +1,6 @@
#pragma once
namespace is::signals
namespace fastsignals
{
namespace detail
{
@@ -72,4 +72,4 @@ decltype(auto) bind_weak(ReturnType (ClassType::*memberFn)(Params... args) const
return std::bind(invoker, args...);
}
} // namespace is::signals
} // namespace fastsignals

View File

@@ -2,7 +2,7 @@
#include <optional>
namespace is::signals
namespace fastsignals
{
/**
@@ -37,4 +37,4 @@ public:
using result_type = void;
};
} // namespace is::signals
} // namespace fastsignals

View File

@@ -2,7 +2,7 @@
#include "signal_impl.h"
namespace is::signals
namespace fastsignals
{
// Connection keeps link between signal and slot and can disconnect them.
@@ -111,4 +111,4 @@ public:
advanced_connection release() noexcept;
};
} // namespace is::signals
} // namespace fastsignals

View File

@@ -2,7 +2,7 @@
#include "function_detail.h"
namespace is::signals
namespace fastsignals
{
// Derive your class from not_directly_callable to prevent function from wrapping it using its template constructor
// Useful if your class provides custom operator for casting to function
@@ -51,4 +51,4 @@ private:
detail::packed_function m_packed;
};
} // namespace is::signals
} // namespace fastsignals

View File

@@ -6,7 +6,7 @@
#include <type_traits>
#include <utility>
namespace is::signals::detail
namespace fastsignals::detail
{
/// Buffer for callable object in-place construction,
/// helps to implement Small Buffer Optimization.
@@ -161,4 +161,4 @@ private:
base_function_proxy* m_proxy = nullptr;
};
} // namespace is::signals::detail
} // namespace fastsignals::detail

View File

@@ -11,7 +11,7 @@
# include "msvc_autolink.h"
#endif
namespace is::signals
namespace fastsignals
{
template <class Signature, template <class T> class Combiner = optional_last_value>
class signal;
@@ -136,7 +136,7 @@ private:
detail::signal_impl_ptr m_slots;
};
} // namespace is::signals
} // namespace fastsignals
namespace std
{
@@ -144,8 +144,8 @@ namespace std
// free swap function, findable by ADL
template <class Signature, template <class T> class Combiner>
void swap(
::is::signals::signal<Signature, Combiner>& sig1,
::is::signals::signal<Signature, Combiner>& sig2)
::fastsignals::signal<Signature, Combiner>& sig1,
::fastsignals::signal<Signature, Combiner>& sig2)
{
sig1.swap(sig2);
}

View File

@@ -5,7 +5,7 @@
#include <memory>
#include <vector>
namespace is::signals::detail
namespace fastsignals::detail
{
class signal_impl
@@ -56,4 +56,4 @@ private:
using signal_impl_ptr = std::shared_ptr<signal_impl>;
using signal_impl_weak_ptr = std::weak_ptr<signal_impl>;
} // namespace is::signals::detail
} // namespace fastsignals::detail

View File

@@ -1,7 +1,7 @@
#pragma once
#include <atomic>
namespace is::signals::detail
namespace fastsignals::detail
{
class spin_mutex
@@ -35,4 +35,4 @@ private:
std::atomic_flag m_busy = ATOMIC_FLAG_INIT;
};
} // namespace is::signals::detail
} // namespace fastsignals::detail

View File

@@ -1,6 +1,6 @@
#pragma once
namespace is::signals
namespace fastsignals
{
namespace detail
{
@@ -21,4 +21,4 @@ struct signal_arg<U&>
template <typename T>
using signal_arg_t = typename detail::signal_arg<T>::type;
} // namespace is::signals
} // namespace fastsignals

View File

@@ -1,6 +1,6 @@
#include "../include/fastsignals/connection.h"
namespace is::signals
namespace fastsignals
{
namespace
{
@@ -248,4 +248,4 @@ advanced_connection advanced_scoped_connection::release() noexcept
return conn;
}
} // namespace is::signals
} // namespace fastsignals

View File

@@ -2,7 +2,7 @@
#include <cstddef>
#include <functional>
namespace is::signals::detail
namespace fastsignals::detail
{
packed_function::packed_function(packed_function&& other) noexcept
@@ -93,4 +93,4 @@ bool packed_function::is_buffer_allocated() const noexcept
&& std::less<const void*>()(m_proxy, &m_buffer[1]);
}
} // namespace is::signals::detail
} // namespace fastsignals::detail

View File

@@ -2,7 +2,7 @@
#include <algorithm>
#include <mutex>
namespace is::signals::detail
namespace fastsignals::detail
{
uint64_t signal_impl::add(packed_function fn)
@@ -81,4 +81,4 @@ size_t signal_impl::count() const noexcept
return m_functions.size();
}
} // namespace is::signals::detail
} // namespace fastsignals::detail

View File

@@ -5,7 +5,7 @@
#include <random>
#include <vector>
using namespace is::signals;
using namespace fastsignals;
namespace
{

View File

@@ -2,7 +2,7 @@
#include <fastsignals/function.h>
#include <array>
using namespace is::signals;
using namespace fastsignals;
namespace
{

View File

@@ -1,7 +1,7 @@
#include "catch2/catch.hpp"
#include <fastsignals/bind_weak.h>
using namespace is::signals;
using namespace fastsignals;
namespace
{

View File

@@ -2,7 +2,7 @@
#include <fastsignals/signal.h>
#include <string>
using namespace is::signals;
using namespace fastsignals;
using namespace std::literals;
namespace