[abandoned] CoolSignal V2.5 A Signal Fast, Support Parallel and Serial , Memory Safe , Embedded

The project is undergoing rework and will be presented on another topic

Cool Signal

LOOK FOR THE NEW VERSIONS HERE
CoolSignal | Fast and Supports ConnectParallel , Efficient and Concise - Resources / Community >Resources - Developer Forum | Roblox

How to Download it ?

Get it NOW From :backhand_index_pointing_down:
Marketplace Store | Releases | Github

FILE LINK | Signal V2.5.5 (9.3 KB)
(PLEASE DOWNLOAD VERSION BEFORE V2.5.5, V2.5.5 IS UNSTABLE , Currently it has known memory bugs and over-closures)


CURRENT VERSION : Version 2.5.5

Report Bugs here and you can ask some questions if you dont understand

Features:

  1. Supports one-way communication
  2. Supports Auto-complete
  3. Support for cross-actors
  4. Use OOP to Simulate the RBXScriptSignal style
  5. Available in DisconnnectAll and Destroy Methods
  6. Defensive programming (Strict Typing-check)
  7. Direct support for Wait and Once instead of helping with Connect
  8. No memory leaks (BASED ON LUAU LINKED LIST)
  9. Good efficiency and very Fast
  10. 600 lines of code are annotated and readable
  11. It can be EMBEDDED
  12. BindableEvents are not created in multiple Actors (only need your actor!)

APIs:
  1. Signal (enableParallel [boolean], uniqueName [string) – uniqueName is for Parallel Luau when enable Parallel
  2. Signal:Connect(func [function]) – Listen to the signal , allowed multi-callbacks
  3. Signal:ConnectParallel(script [Your script], func [function]) – Listen to the signal in parallel , allowed multi-callbacks
  4. Signal:Once(func [function]) – Only Listen to the signal once and disconnect
  5. Signal:Wait() – Yield the thread until the signal is fired
  6. Signal:Fire(…) – Fire the signal and all callbacks will be called
  7. Signal:FireDeferred(…) – Fire the signal and call task.defer()
  8. Signal:DisconnectAll() – Disconnect all connections
  9. Signal:Destroy() – Destroy current object
  10. Signal.isEmpty: () → boolean, – Get isEmpty
  11. Signal.isEmptyParallel: () → boolean, – Get isEmptyParallel
  12. Signal.EnabledParallel: () → boolean, – Get enabledParallel
  13. Signal.GetListenersCounter: () → number, – Get Counter
  14. Signal.GetListenersCounterParallel: () → number, – Get Counter
  15. SignalConnection.Connected: () → boolean, – Get connection status
  16. SignalConnection:Disconnect() – Disconnect current connection

Why do we use it?
we can use it to help communicate between our modules

How to use it?

-- require my module
local Signal = require("./Signal")
-- new a singal Instance
local signalInstance = Signal()
-- now we can enjoy using it


-- If Running On Parallel Luau
--local signalInstance = Signal(true, --[[Your Signal Name]])
-- And you can use ConnectParallel and FireParallel Now
local signalInstanceParallel = Signal(true, "hello")
-- Actor 1
signalInstanceParallel:ConnectParallel(function(a)
	print(a)
end)
-- Actor 2
task.defer(function()
	signalInstanceParallel:Fire("handle")
end)

Benchmarking (Version 2.5.0)

--------Function----------------------------Time--------------------
| Create               | 1.4     μs 							   |
| Fire                 | 0.51    μs 							   |
| Once 			       | 0.5     μs 		 					   |
| Wait                 | 3.23    μs 							   | 
| Connect         	   | 0.7     μs          					   |
| Disconnect      	   | 0.15    μs		   					       |
| DisconnectAll   	   |o(n)*0.2 μs    						       |
| ConnectParallel      | 5       ms 	  						   |
| ConnectAndDisconnect | 5       μs                                |   
| FireManyArgs		   | 41      μs      (1000 args)			   |
| ConnectMany		   | 385     μs     (1000 connections)		   |
| FireAndConnectionMany| 1006.67 μs (1000 connections & Fired 1000)|
--------------------------------------------------------------------

Enjoy this
This signal module uses MIT open source license
You can modify its copy and Choose whether to open source or not

2 Likes

The next release will rewrite the metatables accessor logic and gradually replaces the checks for debug.info

wait so if you were to connect parallel, would firing normally not set it off? since in your example you use FireParallel, where I would’ve thought it would have just been Fire

1 Like


big error !

benchmark (A is yours and B is signal plus)

also really awesome module. holds up well with another signal module i primarily use (signal plus)

1 Like

Because each Actor in a parallel Luau is an independent unit(not thread), there is environmental isolation between them.
Taking the parallel out alone is an efficient decision

1 Like

good job :+1: I’m fixing your issue I don’t seem to be triggering when I’m benchmarking

yes that was actually an “old” error i got when making the bench marker thingy. anyways might as well add a check for error-proofing

1 Like

I found out that you are using parallel support
My signal.new function supports a string parameter but if you add that argument it will enable parallel.
(Well it’s the property name error)

1 Like

Version 2.1.5

Signal V2.1.5.lua (16.4 KB)

  1. Fixed DisconnectAll() when enable ParallelConnection
  2. Added a new type SignalClass
  3. Solved an internal problem

Version 2.1.7 Roadmap

Starting from version 2.1.7, FireParallel will be merged into Fire.
Signal._signalParallelConnections is about to be deprecated
and replace with Signal._parallelConnectionsQueue

For parallel Luau. Signal V2.1.7, a thread lock mechanism will be used to help locate connections.
The current version does not trigger race issues

Notes:
Using DisconnectAll does not clean other Actor connections on CURRENT Version

(coming soon)

1 Like

Version 2.5.0

Signal V 2.5.0.rbxm (8.2 KB)

BIG UPDATES HERE

Updates:

  1. Rewrote all the module
  2. Switch to C style OOP
  3. From now on, external modules will not be allowed to access the inside of the class
  4. Optimizations have been made for parallel Luau connections
  5. Fixed internal bugs
  6. FireParallel method is deprecated
  7. Added Getter Methods to replace the protected attribute in classes
  8. Improved performance and memory
  9. Fixed a known memory leak bug (when create many signals)
  10. Now you can use Signal_new to create new signals in embeddings

Version 2.5.2

Signal V 2.5.2.rbxm (8.2 KB)

Updates:

  1. Fixed some bugs
  2. Modified the type to fit V2.5
  3. Benchmarks were conducted
  4. Now the reqiure module will only return a read-only table
  5. You are not allowed to modify methods and functions anymore

Version 2.5.5

Signal V 2.5.5.rbxm (9.3 KB)

Updates:

  1. Improved structure
  2. Memory is reduced by 1x
  3. Performance improvement by 10~25%
  4. Dictionary was canceled
  5. The bug for the internal pointer bug for inserting connections has been fixed
  6. We cancel Signal Table , just require this and call it Signal()

Hi.

Version 2.6 Roadmap

  1. Reduce module complexity Reduce the amount of code
  2. Explore the Protected and Private properties
  3. Metatable OOP will maybe come back
  4. Rework all the code