Merge "Bug 2938: register serializers for all augmentations"
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / SessionRIBsOut.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.rib.impl;
9
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;
13
14 @Deprecated
15 final class SessionRIBsOut extends AbstractAdjRIBsOut implements Runnable {
16     private final AtomicBoolean scheduled = new AtomicBoolean(false);
17     private final BGPSessionImpl session;
18
19     SessionRIBsOut(final BGPSessionImpl session) {
20         this.session = Preconditions.checkNotNull(session);
21     }
22
23     @Override
24     protected void wantWrite() {
25         if (scheduled.compareAndSet(false, true)) {
26             session.schedule(this);
27         }
28     }
29
30     @Override
31     protected boolean writePDU(final Update pdu) {
32         session.writeAndFlush(pdu);
33         return session.isWritable();
34     }
35
36     @Override
37     public void run() {
38         process();
39     }
40 }