-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
World multithreading #727
base: master
Are you sure you want to change the base?
World multithreading #727
Conversation
011c48c
to
7502658
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This system should be made with more generic prediction usage. So you can have registerLisetener(T listener, Predicate<Event> shouldFirePredicate)
and there is no need to store the IntSet (which is a candidate for hash collisions) since you can use the Collection (which should be moved to the Set interface) in SimplePluginManager eventManager.registerListener(EventListener, Collection<String>)
to
eventManager.registerListener(EventListener, Predicate<Event>)
eventManager.registerListener(EventListener, new Predicate<Event>() {
boolean test(Event event) {
return !(event instanceof WorldEvent && worlds != null && !worlds.contains(((WorldEvent) event).world().folder()));
}
})
Can you also decouple the API / this reference cleanup from the actual world multithreading? Its hard to review in the current state due to that |
This comment has been minimized.
This comment has been minimized.
Can you link me that usage? If there is a IntSet in use in that Manager its for sure a bug and should be fixed ASAP |
1e3470a
to
1bef9e7
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yes, can you open a PR with that here? |
This comment has been minimized.
This comment has been minimized.
b97fe66
to
01c6e98
Compare
- split sync and async scheduler api and implementation - add per-world sync scheduler - move ticking code from GoMintServer to each world - create thread in world constructor - add plugin instance field to plugin class loader and getCallerPluginLoader() method in CallerDetector for world#scheduler() method returning plugin-based - replace main thread check with world thread check - synchronize access to Entity#world - schedule connection close handling onto world thread
- remove sync scheduling from PacketLoginHandler as disconnect is thread safe now - remove constructor arguments from PacketHandlers - update world of player to spawnLocation world of PlayerLoginEvent - make world manager thread safe, start world thread
…prove concurrency in NetworkManager.
…WeakReference, clear syncTaskManager on world unload
…rrentTickTime where used
This comment has been minimized.
This comment has been minimized.
gomint-server/src/main/java/io/gomint/server/world/WorldAdapter.java
Outdated
Show resolved
Hide resolved
…or global commands, also add option to disallow console.
…for command map sending
- Move server.executorService() to server.asyncScheduler() to be notified about exceptions happening - move player to world tick earlier, add newConnections list to each world for that - fix npe in login as spawnLocation can be null - network manager untick queue is now just an arraylist (enough) - Change closing behaviour: - close network later to be able to kick players - disallow new connections when shutting down - players get kicked with "Server closed" instead of just connection closing. - fix potential watchdog npe when thread is dead - report exceptions in world tick and shutdown server - uncaught exception handler reports thread id as well - added a couple more debug log messages
I think it might be now ready to merge. |
A topic to look at is whether we need more safe world access checks, but I think that could be done after merging. |
gomint-api/src/main/java/io/gomint/event/entity/projectile/ProjectileHitBlocksEvent.java
Outdated
Show resolved
Hide resolved
gomint-server/src/main/java/io/gomint/server/util/Precondition.java
Outdated
Show resolved
Hide resolved
gomint-server/src/main/java/io/gomint/server/world/WorldManager.java
Outdated
Show resolved
Hide resolved
gomint-server/src/main/java/io/gomint/server/world/WorldManager.java
Outdated
Show resolved
Hide resolved
gomint-server/src/main/java/io/gomint/server/world/WorldAdapter.java
Outdated
Show resolved
Hide resolved
gomint-server/src/main/java/io/gomint/server/world/WorldAdapter.java
Outdated
Show resolved
Hide resolved
- Remove Command scope system again, Commands are now always bound to active worlds. - Event listeners are now always bound to active worlds. - Removed some more unneeded calls to CommandOutput#markFinished
Closes #715
Closes #728
Closes #751
Documentation PR: gomint/gomint-docs#28
I'd like to get some hints on what else needs to be made multithread-ready.
TODO:
Current design changes to #715:
Also contains a bunch of various fixes as well as some javadoc and code layout fixes.