Merge "Bug 1119 - Optimize generated range checks"
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / concurrent / NotificationManager.java
1 /*
2  * Copyright (c) 2014 Brocade Communications 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
9 package org.opendaylight.yangtools.util.concurrent;
10
11 import java.util.concurrent.RejectedExecutionException;
12
13 /**
14  * Interface for a class that manages queuing and dispatching notifications for multiple listeners.
15  *
16  * @author Thomas Pantelis
17  *
18  * @param <L> the listener type
19  * @param <N> the notification type
20  */
21 public interface NotificationManager<L, N> {
22
23     /**
24      * Submits a notification to be queued and dispatched to the given listener.
25      * <p>
26      * <b>Note:</b> This method may block if the listener queue is currently full.
27      *
28      * @param listener the listener to notify
29      * @param notification the notification to dispatch
30      * @throws RejectedExecutionException if the notification can't be queued for dispatching
31      */
32     void submitNotification( L listener, N notification )
33             throws RejectedExecutionException;
34
35     /**
36      * Submits notifications to be queued and dispatched to the given listener.
37      * <p>
38      * <b>Note:</b> This method may block if the listener queue is currently full.
39      *
40      * @param listener the listener to notify
41      * @param notifications the notifications to dispatch
42      * @throws RejectedExecutionException if a notification can't be queued for dispatching
43      */
44     void submitNotifications( L listener, Iterable<N> notifications )
45             throws RejectedExecutionException;
46
47 }