All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.shaded.vertx.core.net.impl.pool.PoolWaiter Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2021 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */
package com.arangodb.shaded.vertx.core.net.impl.pool;

import com.arangodb.shaded.vertx.core.AsyncResult;
import com.arangodb.shaded.vertx.core.Context;
import com.arangodb.shaded.vertx.core.Handler;
import com.arangodb.shaded.vertx.core.impl.ContextInternal;
import com.arangodb.shaded.vertx.core.impl.EventLoopContext;

/**
 * A waiter for a connection.
 */
public class PoolWaiter {

  static final Listener NULL_LISTENER = new Listener() {
  };

  /**
   * An interface notifying the connection borrower of the waiter lifecycle.
   */
  public interface Listener {

    /**
     * The waiter is moved to the pool wait queue.
     *
     * @param waiter the waiter
     */
    default void onEnqueue(PoolWaiter waiter) {
    }

    /**
     * The waiter is associated with a connection request.
     *
     * @param waiter the waiter
     */
    default void onConnect(PoolWaiter waiter) {
    }
  }

  final PoolWaiter.Listener listener;
  final ContextInternal context;
  final int capacity;
  final Handler>> handler;
  PoolWaiter prev;
  PoolWaiter next;
  boolean disposed;
  boolean queued;

  PoolWaiter(PoolWaiter.Listener listener, ContextInternal context, final int capacity, Handler>> handler) {
    this.listener = listener;
    this.context = context;
    this.capacity = capacity;
    this.handler = handler;
  }

  /**
   * @return the waiter context
   */
  public ContextInternal context() {
    return context;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy