Queue async operations on a per-player basis [WIP]#2005
Queue async operations on a per-player basis [WIP]#2005sgdc3 wants to merge 44 commits intothread-safetyfrom
Conversation
|
Depends on #1992 |
Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.1.0 to 3.1.1. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/changelog.txt) - [Commits](typetools/checker-framework@checker-framework-3.1.0...checker-framework-3.1.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
TuxCoding
left a comment
There was a problem hiding this comment.
I kind of understand what you are doing here. You are trying to perform asynchronous tasks sequential on per player basis. I guess with the goal to reduce conflicts between them? Do you also thought about locks? This allows more flexibility like read/write differentiation, protecting only thread-unsafe operations meanwhile other parts could execute in concurrently and in parallel.
| } | ||
|
|
||
| public void submit(K key, Runnable runnable) { | ||
| executors.computeIfAbsent(key, k -> new SequentialExecutor(scheduler, () -> executors.remove(key))) |
| } | ||
|
|
||
| public void submit(Runnable task) { | ||
| queue.add(task); |
There was a problem hiding this comment.
This doesn't seem thread-safe. Considering two calls to the submit method. Then both tasks will be added, but scheduler.apply() will be invoked twice with two new tasks on the Bukkit scheduler resulting to two new threads.
T1 and T2 are the threads:
T1: 1 iteration of the while loop
-- 1 task remaining
T1: evaluate while(!queue.isEmpty()) -> true - enter while loop
T2: 1 iteration of the while loop
-- queue.poll wasn't executed yet by T1 and so queue is still not empty
-- T2 now removes the last task
T1: queue.poll() - NoSuchElementExeception
There was a problem hiding this comment.
Hmm I see, which pattern should we use instead?
There was a problem hiding this comment.
The easiest solution would be to lock on the queue on isEmpty + poll operations.
|
@games647 I think that both read/write operations needs to be sequential, I can't think about any situation where locks might be better. Can you make some examples? |
Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.2.9 to 42.2.10. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](pgjdbc/pgjdbc@REL42.2.9...REL42.2.10) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.1 to 3.2.2. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](apache/maven-shade-plugin@maven-shade-plugin-3.2.1...maven-shade-plugin-3.2.2) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Addresses #2014
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.2.4 to 3.3.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v3.2.4...v3.3.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Bumps [maxmind-db-gson](https://github.com/maxmind/MaxMind-DB-Reader-java) from 2.0.2-SNAPSHOT to 2.0.3. - [Release notes](https://github.com/maxmind/MaxMind-DB-Reader-java/releases) - [Changelog](https://github.com/maxmind/MaxMind-DB-Reader-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/maxmind/MaxMind-DB-Reader-java/commits) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.1.1 to 3.2.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/changelog.txt) - [Commits](typetools/checker-framework@checker-framework-3.1.1...checker-framework-3.2.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.8.2 to 3.9.0. - [Release notes](https://github.com/apache/maven-site-plugin/releases) - [Commits](apache/maven-site-plugin@maven-site-plugin-3.8.2...maven-site-plugin-3.9.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.2.10 to 42.2.11. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](pgjdbc/pgjdbc@REL42.2.10...REL42.2.11) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Updated Turkish Lang
- "allowMissingThrowsTags" does nothing anymore, cf. checkstyle/checkstyle#7329
Bumps [googleauth](https://github.com/wstrange/GoogleAuth) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/wstrange/GoogleAuth/releases) - [Changelog](https://github.com/wstrange/GoogleAuth/blob/master/NEWS) - [Commits](wstrange/GoogleAuth@1.4.0...1.5.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.2.0 to 3.3.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/changelog.txt) - [Commits](typetools/checker-framework@checker-framework-3.2.0...checker-framework-3.3.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.1.1 to 3.2.0. - [Release notes](https://github.com/apache/maven-javadoc-plugin/releases) - [Commits](apache/maven-javadoc-plugin@maven-javadoc-plugin-3.1.1...maven-javadoc-plugin-3.2.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [mockito-core](https://github.com/mockito/mockito) from 3.3.0 to 3.3.3. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v3.3.0...v3.3.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.2.11 to 42.2.12. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](pgjdbc/pgjdbc@REL42.2.11...REL42.2.12) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.2 to 3.2.3. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](apache/maven-shade-plugin@maven-shade-plugin-3.2.2...maven-shade-plugin-3.2.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [argon2-jvm-nolibs](https://github.com/phxql/argon2-jvm) from 2.6 to 2.7. - [Release notes](https://github.com/phxql/argon2-jvm/releases) - [Changelog](https://github.com/phxql/argon2-jvm/blob/master/CHANGELOG.md) - [Commits](phxql/argon2-jvm@v2.6...v2.7) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Update messages_ru.yml * Update messages_ru.yml
Bumps [HikariCP](https://github.com/brettwooldridge/HikariCP) from 3.4.2 to 3.4.4. - [Release notes](https://github.com/brettwooldridge/HikariCP/releases) - [Changelog](https://github.com/brettwooldridge/HikariCP/blob/dev/CHANGES) - [Commits](brettwooldridge/HikariCP@HikariCP-3.4.2...HikariCP-3.4.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.30.1 to 3.31.1. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](xerial/sqlite-jdbc@3.30.1...3.31.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.3.0 to 3.4.0. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/changelog.txt) - [Commits](typetools/checker-framework@checker-framework-3.3.0...checker-framework-3.4.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [HikariCP](https://github.com/brettwooldridge/HikariCP) from 3.4.4 to 3.4.5. - [Release notes](https://github.com/brettwooldridge/HikariCP/releases) - [Changelog](https://github.com/brettwooldridge/HikariCP/blob/dev/CHANGES) - [Commits](brettwooldridge/HikariCP@HikariCP-3.4.4...HikariCP-3.4.5) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [api](https://github.com/lucko/LuckPerms) from 5.0 to 5.1. - [Release notes](https://github.com/lucko/LuckPerms/releases) - [Commits](LuckPerms/LuckPerms@v5.0...v5.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
* Update messages_br.yml * Update messages_br.yml
Should fix issues due to old Email API usages
Bumps [checker-qual](https://github.com/typetools/checker-framework) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/typetools/checker-framework/releases) - [Changelog](https://github.com/typetools/checker-framework/blob/master/changelog.txt) - [Commits](typetools/checker-framework@checker-framework-3.4.0...checker-framework-3.4.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [maven-shade-plugin](https://github.com/apache/maven-shade-plugin) from 3.2.3 to 3.2.4. - [Release notes](https://github.com/apache/maven-shade-plugin/releases) - [Commits](apache/maven-shade-plugin@maven-shade-plugin-3.2.3...maven-shade-plugin-3.2.4) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [postgresql](https://github.com/pgjdbc/pgjdbc) from 42.2.12 to 42.2.14. - [Release notes](https://github.com/pgjdbc/pgjdbc/releases) - [Changelog](https://github.com/pgjdbc/pgjdbc/blob/master/CHANGELOG.md) - [Commits](pgjdbc/pgjdbc@REL42.2.12...REL42.2.14) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [sqlite-jdbc](https://github.com/xerial/sqlite-jdbc) from 3.31.1 to 3.32.3. - [Release notes](https://github.com/xerial/sqlite-jdbc/releases) - [Changelog](https://github.com/xerial/sqlite-jdbc/blob/master/CHANGELOG) - [Commits](xerial/sqlite-jdbc@3.31.1...3.32.3) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Bumps [maven-site-plugin](https://github.com/apache/maven-site-plugin) from 3.9.0 to 3.9.1. - [Release notes](https://github.com/apache/maven-site-plugin/releases) - [Commits](apache/maven-site-plugin@maven-site-plugin-3.9.0...maven-site-plugin-3.9.1) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
No description provided.