blob: 35e45b88857f5a8878c21c058c62773613adbcb8 [file] [log] [blame]
Madan Jampanie5723dc2015-08-31 14:23:58 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Madan Jampanie5723dc2015-08-31 14:23:58 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.store.service;
17
18/**
19 * The MutexTask interface should be implemented by any class whose
20 * instances distributed across controllers are intended to be executed
21 * in a mutually exclusive fashion.
22 */
23public interface MutexTask {
24
25 /**
26 * Begins the execution of a mutually exclusive task.
27 * The start method will be called once the "lock" is acquired.
28 * After the start method returns the lock is released and some other
29 * instance can take over execution.
30 */
31 void start();
32
33 /**
34 * This method will be called when exclusivity of task execution
35 * can no longer be guaranteed. The implementation should take necessary steps
36 * to halt task execution in order to ensure correctness.
37 */
38 void stop();
39}