Title: Register/Unregister while Raise · Issue #6 · pointcache/BasicEventBus · GitHub
Open Graph Title: Register/Unregister while Raise · Issue #6 · pointcache/BasicEventBus
X Title: Register/Unregister while Raise · Issue #6 · pointcache/BasicEventBus
Description: while raising, if an unregister happens: a listener that was already handled will swap indices with the last element on unregister, making the last listener being not invoked iterating backwards has the issue just the other way arround: ...
Open Graph Description: while raising, if an unregister happens: a listener that was already handled will swap indices with the last element on unregister, making the last listener being not invoked iterating backwards ha...
X Description: while raising, if an unregister happens: a listener that was already handled will swap indices with the last element on unregister, making the last listener being not invoked iterating backwards ha...
Opengraph URL: https://github.com/pointcache/BasicEventBus/issues/6
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Register/Unregister while Raise","articleBody":"while raising, if an unregister happens:\n\n- a listener that was already handled will swap indices with the last element on unregister, making the last listener being not invoked\n- iterating backwards has the issue just the other way arround: that newly registered listeners would be not detected.\n- in general raise should be somewhat \"atomic\" and adding listeners to an event that is being raised right now should not have immediate effect, but only on the next raise invocation.\n\nIn my changes I keep a list of \"mutations\" if raise is being invoked right now. also, Raise could be invoked in a nested fashion. \n\n```\n public static void Raise(T ev)\n {\n...\n raiseStackDepth++;\n try\n {\n for (int i = 0, n = bindings.Count; i \u003c n; i++)\n {\n var internalBind = bindings[i];\n internalBind.OnEvent?.Invoke(ev);\n internalBind.OnEventArgs?.Invoke();\n }\n }\n finally\n {\n raiseStackDepth--;\n if (raiseStackDepth == 0)\n {\n foreach (var mutation in mutations)\n {\n if (mutation.Type == EventBindingMutation\u003cT\u003e.MutationType.Register)\n Register(mutation.Binding);\n else if (mutation.Type == EventBindingMutation\u003cT\u003e.MutationType.Unregister) \n Unregister(mutation.Binding);\n }\n mutations.Clear();\n }\n }\n...\n }\n```\n\n---\n\nfurthermore: \nhandling the array manually has barely any benefit over using a List\u003c\u003e as resizing logic is basically the same.\n\n","author":{"url":"https://github.com/soraphis","@type":"Person","name":"soraphis"},"datePublished":"2026-01-07T10:56:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/6/BasicEventBus/issues/6"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1b2a0b76-430f-8316-d51b-ec8960bf241a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9578:316666:1B9A3:2246B:698E63B2 |
| html-safe-nonce | 071b956f1cd67915d2fc9a1b7e2478e0425b29f64a49eedb9b70e7dcbdaed7e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTc4OjMxNjY2NjoxQjlBMzoyMjQ2Qjo2OThFNjNCMiIsInZpc2l0b3JfaWQiOiIxMzA0NDM1NTgzMDc0ODUzODEwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | bb04487238d67116adb28a6ba4aa8afe99108120fca91d95b3c43cd92ad7dddd |
| hovercard-subject-tag | issue:3788273095 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pointcache/BasicEventBus/6/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b09cc39d93d9206e3013ed3a6f0efa8ee23279a22b47ede699818995c01f1d0/pointcache/BasicEventBus/issues/6 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b09cc39d93d9206e3013ed3a6f0efa8ee23279a22b47ede699818995c01f1d0/pointcache/BasicEventBus/issues/6 |
| og:image:alt | while raising, if an unregister happens: a listener that was already handled will swap indices with the last element on unregister, making the last listener being not invoked iterating backwards ha... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | soraphis |
| hostname | github.com |
| expected-hostname | github.com |
| None | 666e30cc1de8ebdf458084bf731e95deba4f074a5008f91b50803aa9a71e3725 |
| turbo-cache-control | no-preview |
| go-import | github.com/pointcache/BasicEventBus git https://github.com/pointcache/BasicEventBus.git |
| octolytics-dimension-user_id | 5315202 |
| octolytics-dimension-user_login | pointcache |
| octolytics-dimension-repository_id | 90581494 |
| octolytics-dimension-repository_nwo | pointcache/BasicEventBus |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 90581494 |
| octolytics-dimension-repository_network_root_nwo | pointcache/BasicEventBus |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c5daa44975c44e187dd9ea0d761c37973489d508 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width