#Suphi's Signal Module
1 messages · Page 1 of 1 (latest)
Features
No Parameter Limitations [2;36mUnlike ROBLOX Events there are no parameter limitations[0m
Store Values Inside The Connection [2;36mPass values when connecting a function to be passed to the fuction[0m
Table Reference [2;36mPassing a table will pass a refrence and does not deep clone the table[0m
Fire In Order [2;36mEvents are fired in the same order they where connected in[0m
Does not relay on workspace.SignalBehavior [2;36mAlways spawns signals even if signal behavior is set to deferred[0m
Familiar [2;36mWorks a lot like RBXScriptSignal and RBXScriptConnection[0m
BENCHMARKS
| FastSignal | SuphisSignal | GoodSignal | SimpleSignal | RobloxSignal |
------------------------------------------------------------------------------------
New | [2;36m0.2[0m | [2;36m?[0m | [2;36m0.2[0m | [2;36m0.1[0m | [2;36m1.1[0m |
Connect | [2;36m0.5[0m | [2;36m?[0m | [2;36m0.4[0m | [2;36m0.3[0m | [2;36m2.3[0m |
Disconnect | [2;36m0.1[0m | [2;36m?[0m | [2;36m139.8[0m | [2;36m3.8[0m | [2;36m39.0[0m |
Fire | [2;36m2.0[0m | [2;36m? & ?[0m | [2;36m31.3[0m | [2;36m104.9[0m | [2;36m30.6[0m |
Wait | [2;36m3.5[0m | [2;36m?[0m | [2;36m3.9[0m | [2;36m5.3[0m | [2;36m5.4[0m |
DOWNLOAD BENCHMARK
#1042810934277713931 message
microseconds to complete (lower is better)
Fire is the most important benchmark as that's what your going to be doing the most
SuphisSignal vs FastSignal
[2;35mFastSignal[0m does not create new threads when it fires connections this makes [2;35mFastSignal[0m fast but if any of the connections use async functions or have [2;36mtask.wait()[0m it will block the next connections from fireing until the current connection has finished [2;35mSuphisSignal[0m has a method called FastFire that works like [2;35mFastSignal[0m
SuphisSignal vs GoodSignal
[2;35mSuphisSignal[0m works a lot like [2;35mGoodSignal[0m but with some small differences
1) [2;35mGoodSignal[0m only caches 1 thread where [2;35mSuphisSignal[0m caches 16 threads it creates
2) [2;35mGoodSignal[0m and [2;35mSuphisSignal[0m both use linked lists but [2;35mSuphisSignal[0m uses doubly linked list this allows [2;35mSuphisSignal[0m to disconnect connections without traversing the list
3) [2;35mGoodSignal[0m new connections are added to the front of the list making connections fire in reverse order [2;35mSuphisSignal[0m adds new connections to the end of the list making them fire in the same order as they where connected
DOWNLOAD
https://create.roblox.com/marketplace/asset/11670710927/
local signalModule = require(11670710927)
SIGNAL MODULE
CONSTRUCTORS
new() [2;34m signal
[2;36mReturns a new signal object
SIGNAL OBJECT
PROPERTIES
Connections [2;34m number [2;33m 0 [2;31m READ ONLY
[2;36mThe amount of connections connected to this signal
EVENTS
Connected(connected: [2;34mboolean[0m, signal: [2;34mSignal[0m) [2;34m nil
[2;36mFires when the signal gets its first connection or if it removes its last connection
METHODS
Connect(func: [2;34mfunction[0m, arguments...: [2;34mtuple[0m) [2;34m connection
[2;36mConnects the given function to the event and returns an connection that represents it
``````ansi
Once(func: [2;34mfunction[0m, arguments...: [2;34mtuple[0m) [2;34m connection
[2;36mConnects the given function to the event (for a single invocation) and returns an connection that represents it
``````ansi
Wait(arguments...: [2;34mtuple[0m) [2;34m tuple
[2;36mYields the current thread until the signal fires and returns the arguments provided by the signal
``````ansi
Fire(arguments...: [2;34mtuple[0m) [2;34m nil
[2;36mFires the event
``````ansi
FastFire(arguments...: [2;34mtuple[0m) [2;34m nil
[2;36mFires the event without creating threads
``````ansi
DisconnectAll() [2;34m nil
[2;36mDisconnects all connections from the signal
CONNECTION OBJECT
PROPERTIES
Signal [2;34m signal? [2;33m Signal [2;31m READ ONLY
[2;36mThe signal object this connection is connected to or nil
METHODS
Disconnect() [2;34m nil
[2;36mDisconnects the connection from the signal
SIMPLE EXAMPLE
-- Require the ModuleScript
local signalModule = require(11670710927)
-- create a signal object
local signal = signalModule.new()
-- connect a function to the signal
local connection = signal:Connect(function(...)
print(...)
end)
-- fire the signal
signal:Fire("Hello world!")
-- Disconnect the connection from the signal
connection:Disconnect()
DISCONNECT ALL EXAMPLE
local signalModule = require(11670710927)
local signal = signalModule.new()
signal:Connect(function(...) print("Conection1", ...) end)
signal:Connect(function(...) print("Conection2", ...) end)
signal:Connect(function(...) print("Conection3", ...) end)
signal:Fire("Hello world!")
-- Disconnect all connections from the signal
signal:DisconnectAll()
-- fire the signal again this time nothing will print to output because we disconnected all connections
signal:Fire("Hello world!")
ONCE EXAMPLE
local signalModule = require(11670710927)
local signal = signalModule.new()
-- connection a function to only be called once
signal:Once(function(...) print(...) end)
signal:Fire("Hello world!")
-- fire the signal again this time nothing will print to output because once will automatically disconnect once it gets fired
signal:Fire("Hello world!")
WAIT EXAMPLE
local signalModule = require(11670710927)
local signal = signalModule.new()
-- fire after a 10 second delay
task.delay(10, signal.Fire, signal, "Hello world!")
-- wait for the signal to fire then print it
print(signal:Wait())
ARGUMENTS EXAMPLE
local function Event(...)
print(...) -- Hello World Goodbye 69
end
local signalModule = require(11670710927)
local signal = signalModule.new()
signal:Connect(Event, "Goodbye", 69) -- connect to the signal and save the values Goodbye and 69 into the connection
signal:Fire("Hello", "World")
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
_ _
version 0.5 is now out
you can now pass custom arguments into Connect, Once and Wait that will be past to the function when called
Suphi's Signal Module
version 1.0 is now out
added Connections property
added Connected callback to detect when the signal gets connections
improved proxy
under the hood changes
Do signals automatically garbage collect, or do we have to manually gc them
Once all references to the explosion are gone, is it the same for the signal?
If you have no reference to them then they will garbage collect
Got it, thanks
This is peak
@patent harness sorry for the ping, is this faster than fastsignal? Im on mobile and the formatting is really bad.
no
its slower then fast signal and good signal
but only a small difference then good signal
One message removed from a suspended account.
One message removed from a suspended account.
its faster at disconnected then good signal
my module was not designed to be fast it was designed to be safe
so that people could not break the datastore module
One message removed from a suspended account.
but i have a fast signal module i use in my own games but its not safe
One message removed from a suspended account.
i did in the chat channel a long time ago but its not really designed for public use
it does not use the standered connection class
One message removed from a suspended account.
Because it does not create new threads
Compared to LemonSignal, does this outperform it?
don't know but this is not the fastest signal out there
when creating this module it was not designed to be fast but to work well with SDM and to be sandboxed
I could really use it.
check out global framework its signal module is very fast
lemon signal sucks
orange signal is way better trust
I do got one that outperforms LemonSignal and Suphi's while still being determinstic
This was comparison I just tried
This got 1000 connections lol
Buh just one I wrote myself
But Suphi's is very good but not deterministic if that is important
And then Suphi's
I switched my signal from task.spawn to task.defer here to match Suphi's
But mine fires in determined order since using a linked list
But all are good :D
I just changed mine now but idk if there issue but everything I've tested works fine
this module is different to the one in GF this one is deterministic
Yeah I compared to GF one
Also what is difference between coroutine.resume() and task.spawn()
So if I got
this for threads would calling it with coroutine.resume() have different outcome than task.spawn()
@patent harness I've been using this module recently for my projects (Love it, thx). I'm trying to better understand thread manipulation so I've been looking at it's source a bit more and was wondering what this block of code does (Lines 96 to 100).
From what it looks like I know its for removing a connection and resetting the linked list's start and tail, but what does that very last line really mean, mainly the task.defer part.
if signal.__public.Connections == 0 and signal.__public.Connected ~= nil then task.defer(signal.__public.Connected, false, proxy) end
Cause I dont see any threads or functions named connected
I don't know its been a long time since iv looked at this code
Have you tried other signal modules?
Nah not really
Ima play around with the code of this one and see of and where that line originates from