Skip to content

Commit 7023e72

Browse files
committed
Thread-based implementation
1 parent 2f563c3 commit 7023e72

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/Overture.luau

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CollectionService = game:GetService("CollectionService")
2020
]=]
2121
const Overture = {}
2222

23-
const LibrarySignalCache: {[string]: {BindableEvent}} = {}
23+
const LibrarySignalCache = {}
2424
const Libraries: {[string]: ModuleScript} = {}
2525

2626
const IsClient = RunService:IsClient()
@@ -136,10 +136,6 @@ function Overture:LoadLibrary(Index: string, NamedImports: {string}?): any?
136136
else
137137
assert(IsClient, `The library "{Index}" does not exist!`)
138138

139-
LibrarySignalCache[Index] = (LibrarySignalCache[Index] or {})
140-
const Signal = Instance.new("BindableEvent")
141-
table.insert(LibrarySignalCache[Index], Signal)
142-
143139
const CallStack = `{debug.traceback("Stack Begin")}Stack End`
144140
local DebugThread: thread? do
145141
if IsDebug then
@@ -155,7 +151,10 @@ function Overture:LoadLibrary(Index: string, NamedImports: {string}?): any?
155151
end
156152
end
157153

158-
local Object = Signal.Event:Wait()
154+
LibrarySignalCache[Index] = (LibrarySignalCache[Index] or {})
155+
table.insert(LibrarySignalCache[Index], coroutine.running())
156+
157+
local Object = coroutine.yield()
159158

160159
if DebugThread then
161160
pcall(task.cancel, DebugThread)
@@ -275,8 +274,8 @@ task.spawn(BindToTag, "oLibrary", function(Object)
275274
return
276275
end
277276

278-
for _, Signal in LibrarySignalCache[Object.Name] do
279-
Signal:Fire(Object)
277+
for _, Thread in LibrarySignalCache[Object.Name] do
278+
task.spawn(Thread)
280279
end
281280

282281
LibrarySignalCache[Object.Name] = nil

0 commit comments

Comments
 (0)