tarqd / slimsig Goto Github PK
View Code? Open in Web Editor NEWA light-weight alternative to Boost::Signals2 and SigSlot++
License: MIT License
A light-weight alternative to Boost::Signals2 and SigSlot++
License: MIT License
If the user passes an R-Value reference to a signal with multiple slots I imagine that only the first slot would have access to it.
If you disconnect a connection, slot_count()
will be inaccurate until you call emit()
.
We should keep track of the count manually
Not sure how useful this is. Might not be worth complicating the core but it shouldn't impact performance since void return types can be specialized for
shared_ptr
s are used by connections to keep them valid even after they have been disconnected or the signal has been disposed. The pro's of this are it reduces the chance of a segfault or other nasty bugs without the user having to think about it.
Downsides are they are expensive, requiring an extra level of indirection and more heap allocations than necessary. You can of course avoid heap allocations by using a memory-pool or other custom allocator but it seems annoying to have to work around it like that.
Alternatives would be store the slot functions directly in the underlying vector with a unique id or "cookie" which can be returned and stored by the connection object instead of a shared_ptr. You would need to do a brute-force lookup to remove it or check it's status but really that won't cost much considering your average list of slots is going to fit in the processors cache quite nicely.
If you call connection#disconnect
while the signal
is emitting, it will modify the slot list and cause it not to be fired if it hasn't been already. This is contradicts the expections of users of node's EventEmitter
or boost::signals2
It just doesn't seem natural to try and handle multithreaded concurrency this level. It's very app-specific so should be left to higher level libraries. Will be removing the ThreadPolicy templates but will replace it with a SignalTraits template to allow for custom slot_id types (if you need more than unsigned long long
provides, though you definitely shouldn't
We want this to behave similar to nodes EventEmitter .
it("should be re-entrant", [&] { // see test.js
unsigned count{0};
signal.connect([&]{
++count;
if (count == 1) {
signal.connect_once([&]{
++count;
});
signal.emit();
};
});
signal.emit();
AssertThat(count, Equals(3u))
});
Should leave the count with 3, just like the equivilent code would with node. I have a solution for this that I'm cleaning up.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.