BenScr.Signals 1.0.0

dotnet add package BenScr.Signals --version 1.0.0
                    
NuGet\Install-Package BenScr.Signals -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BenScr.Signals" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BenScr.Signals" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="BenScr.Signals" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BenScr.Signals --version 1.0.0
                    
#r "nuget: BenScr.Signals, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BenScr.Signals@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BenScr.Signals&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=BenScr.Signals&version=1.0.0
                    
Install as a Cake Tool

BenScr.Signals

C++20 synchronous signals and slots with scoped connections. Callbacks run in connection order, with defined behavior for nested emissions, connection changes and destruction while a callback is running. The library consists of one independently includable header and uses only the C++ standard library.

Native NuGet

Install BenScr.Signals version 1.0.0 into a C++ .vcxproj using Visual Studio's NuGet package manager or its Package Manager Console:

Install-Package BenScr.Signals -Version 1.0.0

Use a C++20 language standard or newer. The package's build/native/BenScr.Signals.props adds the include directory; its matching .targets adds the header to the project and checks that it exists. There is no binary library to link, no managed runtime, and no prebuilt compiler ABI requirement. Native installation uses packages.config; this is not a .NET library or a native PackageReference package.

#include <benscr/signals/signal.hpp>

BenScr::Signals::Signal<int> scoreChanged;
int score = 0;
auto connection = scoreChanged.Connect([&](int amount) { score += amount; });
scoreChanged.Emit(10);
connection.Disconnect();

Keep the returned Connection alive for as long as the callback should remain connected. Its destructor disconnects automatically. Captured references must outlive every invocation.

CMake

With the source checked out, build and install:

cmake -S . -B out/release -DCMAKE_BUILD_TYPE=Release
cmake --build out/release --config Release
ctest --test-dir out/release -C Release --output-on-failure
cmake --install out/release --config Release --prefix /path/to/install

Then use the separately installed CMake package:

find_package(BenScrSignals 1 CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE BenScr::Signals)

Pass the installation prefix through CMAKE_PREFIX_PATH. The interface target supplies the include path and C++20 requirement. Alternatively use add_subdirectory and the same target; tests and examples default to off when included as a subproject.

Behavior

  • Signal<Args...> and Connection are movable and noncopyable. Moved connections keep their subscription; moved signals transfer their subscriptions and leave an empty, reusable source. Move assignment replaces the destination's old subscriptions.
  • Each Emit snapshots the current connection order. Connections added during an emission start with the next emission, including a nested one. Disconnected callbacks are skipped even when already in a snapshot.
  • Disconnecting or destroying a signal during its callback is supported. The active callback remains alive until it returns or unwinds. Destroying the signal disconnects its remaining callbacks. Handles use weak ownership and cannot retain the signal.
  • Values are copied separately into each callback; lvalue references are shared. Use Signal<const T&> for a noncopyable value. Rvalue-reference signatures are rejected.
  • Callback exceptions propagate and stop that emission. Earlier side effects and connection changes remain. Snapshot allocation failure invokes no callbacks.
  • Access to a signal and its connections requires a single thread or external synchronization. Calls are synchronous; no queue, worker, thread-safety or recursion limit is supplied. A callback must arrange to terminate recursive emission.

See the API and lifetime contract, verification, migration notes, changelog and provenance. The Windows configuration is MSVC v143 x64; Linux CI exercises GCC 14 and Clang 18 with AddressSanitizer and UndefinedBehaviorSanitizer. Other compilers and platforms are not part of this verification matrix.

License

Distributed under the original custom Ben Schneider license. Preserve its attribution requirements in source and binary redistribution.

Created by Ben Schneider — https://github.com/Ben-Scr

Product Compatible and additional computed target framework versions.
native native is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 106 11/2/2026