2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import com.google.common.base.Preconditions;
11 import java.util.concurrent.atomic.AtomicBoolean;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
15 final class SessionRIBsOut extends AbstractAdjRIBsOut implements Runnable {
16 private final AtomicBoolean scheduled = new AtomicBoolean(false);
17 private final BGPSessionImpl session;
19 SessionRIBsOut(final BGPSessionImpl session) {
20 this.session = Preconditions.checkNotNull(session);
24 protected void wantWrite() {
25 if (scheduled.compareAndSet(false, true)) {
26 session.schedule(this);
31 protected boolean writePDU(final Update pdu) {
32 session.writeAndFlush(pdu);
33 return session.isWritable();