Glowstone icon indicating copy to clipboard operation
Glowstone copied to clipboard

Async events

Open kamcio96 opened this issue 9 years ago • 7 comments

md_5 did simple non blocking event system: https://github.com/SpigotMC/BungeeCord/blob/master/api/src/main/java/net/md_5/bungee/api/event/AsyncEvent.java

We can make something similar. #215 shows how it can be helpful. What do you think?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

kamcio96 avatar Feb 20 '16 14:02 kamcio96

https://github.com/GlowstonePlusPlus/Glowkit/blob/bukkit%2Bglowkit/src/main/java/org/bukkit/event/Event.java#L32 ?

mastercoms avatar Mar 07 '16 16:03 mastercoms

@mastercoms that events are called from other thread (not main), and it is only used for synchronization there

I mean to add way to delay event, like BungeeCord has

kamcio96 avatar Mar 07 '16 22:03 kamcio96

This ticket needs categorization on the waffle board.

Has this ticket seen any movement or has there been any action expected since the previous comment?

gdude2002 avatar Jun 22 '16 11:06 gdude2002

So the server should create a new Thread for each async event?

VaiTon avatar Jul 16 '16 18:07 VaiTon

No. Small example: We have PlayerSpawnLocationEvent, it is called in main thread. Location is saved in mysql, so java will wait for that data. It cause some lags :confused:

Solution:

  • event handler mark event like in BungeeCord event.registerIntend
  • plugin will create new thread (server dosen't care about it) and get needed data
  • event.setSpawnLocation(locationFromMysql);
  • call event.completeIntend
  • server will finish event in main thread (ofc in next tick)

kamcio96 avatar Jul 16 '16 19:07 kamcio96

Any updates on this issue?

heisluft avatar Apr 25 '19 08:04 heisluft

No, there's been no movement on this.

mastercoms avatar Apr 25 '19 09:04 mastercoms