blob: 0caff9c1ab07452df2be4237734871ff7d65ebd5 [file] [log] [blame]
Puneet Lall9c94ab32014-12-02 13:12:53 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
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 */
16
17package com.android.camera.async;
18
19/**
20 * An interface for updating thread-shared state from producer threads with
21 * real-time requirements.
22 * <p>
23 * Depending on how consumers need to access updates, the following
24 * implementations may be used:
25 * <ul>
26 * <li>Synchronous access to every update: {@link ConcurrentBufferQueue}</li>
27 * <li>Synchronous access to a single update: {@link UpdatableCountDownLatch}</li>
28 * <li>Polling: {@link ConcurrentState}</li>
29 * <li>Callbacks: {@link ConcurrentState}</li>
30 * </ul>
31 * </p>
32 */
33public interface Updatable<T> {
34 /**
35 * Implementations MUST ALWAYS satisfy the following constraints:
36 * <ul>
37 * <li>Return quickly, without performing any expensive work.</li>
38 * <li>Execute in a predictable, stable, amount of time.</li>
39 * <li>Never block.</li>
40 * <li>Be thread-safe.</li>
41 * <li>Never leak control of the thread on which they are invoked. (e.g.
42 * invoke callbacks which may violate the above constraints)</li>
43 * </ul>
44 */
45 public void update(T t);
46}