@quenty/signal 7.5.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [7.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/signal@7.5.0...@quenty/signal@7.6.0) (2024-09-25)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Selene doesn't know debug.getmemorycategory() ([0c613a3](https://github.com/Quenty/NevermoreEngine/commit/0c613a3ae0b6ba6a4cda511f572220bfa951c70d))
12
+
13
+
14
+ ### Features
15
+
16
+ * MemoryCategory is tracked properly in signal (Not sure what the perf implications of this are) ([4d43b0c](https://github.com/Quenty/NevermoreEngine/commit/4d43b0c0c07fd5d24335b1801ca96c58d37ba149))
17
+
18
+
19
+
20
+
21
+
6
22
  # [7.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/signal@7.4.0...@quenty/signal@7.5.0) (2024-09-25)
7
23
 
8
24
  **Note:** Version bump only for package @quenty/signal
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/signal",
3
- "version": "7.5.0",
3
+ "version": "7.6.0",
4
4
  "description": "A simple signal implementation for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -32,5 +32,5 @@
32
32
  "dependencies": {
33
33
  "@quenty/loader": "^10.5.0"
34
34
  },
35
- "gitHead": "41715b15e2b48b2d22ff4f5277a8d4b7a0d32ef3"
35
+ "gitHead": "9b17fe79cddd071f0f06a9d35184e76b44bd6fe6"
36
36
  }
@@ -44,25 +44,33 @@
44
44
  ]=]
45
45
 
46
46
  -- The currently idle thread to run the next handler on
47
- local freeRunnerThread = nil
47
+ local freeRunnerThreadLookup = {}
48
48
 
49
49
  -- Function which acquires the currently idle handler runner thread, runs the
50
50
  -- function fn on it, and then releases the thread, returning it to being the
51
51
  -- currently idle one.
52
52
  -- If there was a currently idle runner thread already, that's okay, that old
53
53
  -- one will just get thrown and eventually GCed.
54
- local function acquireRunnerThreadAndCallEventHandler(fn, ...)
55
- local acquiredRunnerThread = freeRunnerThread
56
- freeRunnerThread = nil
54
+ local function acquireRunnerThreadAndCallEventHandler(memoryCategory, fn, ...)
55
+ debug.setmemorycategory(memoryCategory)
56
+
57
+ local acquiredRunnerThread = freeRunnerThreadLookup[memoryCategory]
58
+ freeRunnerThreadLookup[memoryCategory] = nil
57
59
  fn(...)
58
60
  -- The handler finished running, this runner thread is free again.
59
- freeRunnerThread = acquiredRunnerThread
61
+ freeRunnerThreadLookup[memoryCategory] = acquiredRunnerThread
60
62
  end
61
63
 
62
64
  -- Coroutine runner that we create coroutines of. The coroutine can be
63
65
  -- repeatedly resumed with functions to run followed by the argument to run
64
66
  -- them with.
65
- local function runEventHandlerInFreeThread()
67
+ local function runEventHandlerInFreeThread(memoryCategory)
68
+ if #memoryCategory == 0 then
69
+ debug.setmemorycategory("signal_unknown")
70
+ else
71
+ debug.setmemorycategory(memoryCategory)
72
+ end
73
+
66
74
  -- Note: We cannot use the initial set of arguments passed to
67
75
  -- runEventHandlerInFreeThread for a call to the handler, because those
68
76
  -- arguments would stay on the stack for the duration of the thread's
@@ -186,15 +194,18 @@ end
186
194
  @param ... T -- Variable arguments to pass to handler
187
195
  ]=]
188
196
  function Signal:Fire(...)
197
+ -- selene: allow(incorrect_standard_library_use)
198
+ local memoryCategory = debug.getmemorycategory()
199
+
189
200
  local item = self._handlerListHead
190
201
  while item do
191
202
  if item._connected then
192
- if not freeRunnerThread then
193
- freeRunnerThread = coroutine.create(runEventHandlerInFreeThread)
203
+ if not freeRunnerThreadLookup[memoryCategory] then
204
+ freeRunnerThreadLookup[memoryCategory] = coroutine.create(runEventHandlerInFreeThread)
194
205
  -- Get the freeRunnerThread to the first yield
195
- coroutine.resume(freeRunnerThread)
206
+ coroutine.resume(freeRunnerThreadLookup[memoryCategory], memoryCategory)
196
207
  end
197
- task.spawn(freeRunnerThread, item._fn, ...)
208
+ task.spawn(freeRunnerThreadLookup[memoryCategory], memoryCategory, item._fn, ...)
198
209
  end
199
210
  item = item._next
200
211
  end