Skip to content
forked from xxDark/ssbus

Supersonic, lightweight event bus

License

Notifications You must be signed in to change notification settings

func-solutions/ssbus

 
 

Repository files navigation

ssbus - Supersonic, lightweight event bus

Example usage:

public class HelloBusTest {

    private static final int N = Integer.MAX_VALUE;

    public static void main(String[] args) {
        Bus<Event> bus = new Bus<>(Event.class);
        bus.register(
                e -> {
                    e.message = "Hello from lambdas!";
                },
                100);
        bus.register(EventListener.class);
        long now = System.currentTimeMillis();
        for (int i = 0; i < N; i++) {
            Event e = new Event("Hello, World!");
            bus.unsafeFireAndForget(e);
        }
        System.out.println(System.currentTimeMillis() - now);
    }

    public static final class EventListener {
        @Listener
        public static void onEvent(Event e) {
            e.message = "Hello from hand-crafted classes!";
        }
    }

    public static final class Event {
        String message;

        public Event(String message) {
            this.message = message;
        }
    }
}

TODO:

  • JMH Benchmarks
  • Java 9+ support

About

Supersonic, lightweight event bus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%