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;
12 import java.util.concurrent.atomic.AtomicBoolean;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
16 final class SessionRIBsOut extends AbstractAdjRIBsOut implements Runnable {
17 private final AtomicBoolean scheduled = new AtomicBoolean(false);
18 private final BGPSessionImpl session;
20 SessionRIBsOut(final BGPSessionImpl session) {
21 this.session = Preconditions.checkNotNull(session);
25 protected void wantWrite() {
26 if (scheduled.compareAndSet(false, true)) {
27 session.schedule(this);
32 protected boolean writePDU(final Update pdu) {
33 session.writeAndFlush(pdu);
34 return session.isWritable();