@@ -0,0 +1,1630 @@
+package net.kencochrane.raven.connection;%0A%0Aimport net.kencochrane.raven.event.LoggedEvent;%0A%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0A/**%0A * Asynchronous usage of a connection.%0A * %3Cp%3E%0A * Instead of synchronously sending each event to a connection, use a ThreadPool to establish the connection%0A * and submit the event.%0A * %3C/p%3E%0A */%0Apublic class AsyncConnection implements Connection %7B%0A    /**%0A     * Connection used to actually send the events.%0A     */%0A    private final Connection actualConnection;%0A    // TODO: Allow the user to change to a custom executor?%0A    private final ExecutorService executorService = Executors.newCachedThreadPool();%0A%0A    /**%0A     * Create a connection which will rely on an executor to send events.%0A     *%0A     * @param actualConnection connection used to send the events.%0A     */%0A    public AsyncConnection(Connection actualConnection) %7B%0A        this.actualConnection = actualConnection;%0A    %7D%0A%0A    @Override%0A    public void send(LoggedEvent event) %7B%0A        // TODO: Consider adding an option to wait when it's full?%0A        executorService.execute(new LoggedEventSubmitter(event));%0A    %7D%0A%0A    /**%0A     * Simple runnable using the %7B@link #send(net.kencochrane.raven.event.LoggedEvent)%7D method of the%0A     * %7B@link #actualConnection%7D.%0A     */%0A    private final class LoggedEventSubmitter implements Runnable %7B%0A        private final LoggedEvent event;%0A%0A        private LoggedEventSubmitter(LoggedEvent event) %7B%0A            this.event = event;%0A        %7D%0A%0A        @Override%0A        public void run() %7B%0A            actualConnection.send(event);%0A        %7D%0A    %7D%0A%7D%0A

Add a connection to send events asynchronously