Skip to content
This repository has been archived by the owner on Jul 28, 2022. It is now read-only.

Commit

Permalink
Patched solo Studio hanging issue on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleitnick committed Feb 4, 2019
1 parent 43b8877 commit 1e3952f
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/ServerStorage/Aero/Services/DataService.modulescript.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ function DataService:Start()
self.GameClosing = false

local function FireBoundToCloseCallbacks()

--[[ CONCURRENCY DISABLED DUE TO BINDTOCLOSE YIELDING BUG
local thread = coroutine.running()
local numBinded = #boundToCloseFuncs
if (numBinded == 0) then return end
Expand All @@ -285,6 +288,29 @@ function DataService:Start()
end)()
end
coroutine.yield()
]]

-- Temporary patch using BindableEvent instead of coroutines:
local numBinded = #boundToCloseFuncs
if (numBinded == 0) then return end
local bindable = Instance.new("BindableEvent")
local numCompleted = 0
for _,func in pairs(boundToCloseFuncs) do
spawn(function()
local success, err = pcall(func)
if (not success) then
warn("BindToClose function errored: " .. tostring(err))
end
numCompleted = (numCompleted + 1)
if (numCompleted == numBinded) then
bindable:Fire()
end
end)
end
bindable.Event:Wait()
bindable:Destroy()

end

-- Flush cache:
Expand All @@ -301,7 +327,8 @@ function DataService:Start()
local function GameClosing()
self.GameClosing = true
FireBoundToCloseCallbacks()
self:FlushAllConcurrent()
--self:FlushAllConcurrent()
self:FlushAll()
end

game:GetService("Players").PlayerRemoving:Connect(PlayerRemoving)
Expand Down

0 comments on commit 1e3952f

Please sign in to comment.