Search in sources :

Example 1 with QueueThread

use of io.vertx.up.web.thread.QueueThread in project vertx-zero by silentbalanceyh.

the class ReceiptInquirer method scan.

@Override
public Set<Receipt> scan(final Set<Class<?>> queues) {
    final List<QueueThread> threadReference = new ArrayList<>();
    /**
     * 3.1. Build Metadata *
     */
    for (final Class<?> queue : queues) {
        final QueueThread thread = new QueueThread(queue);
        threadReference.add(thread);
        thread.start();
    }
    /**
     * 3.2. Join *
     */
    Fn.safeJvm(() -> {
        for (final QueueThread item : threadReference) {
            item.join();
        }
    }, LOGGER);
    /**
     * 3.3. Return *
     */
    final Set<Receipt> receipts = new HashSet<>();
    Fn.safeJvm(() -> {
        for (final QueueThread item : threadReference) {
            receipts.addAll(item.getReceipts());
        }
    }, LOGGER);
    return receipts;
}
Also used : Receipt(io.vertx.up.atom.worker.Receipt) ArrayList(java.util.ArrayList) QueueThread(io.vertx.up.web.thread.QueueThread) HashSet(java.util.HashSet)

Aggregations

Receipt (io.vertx.up.atom.worker.Receipt)1 QueueThread (io.vertx.up.web.thread.QueueThread)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1