FastThreadState.h revision a18f644ce5eb4ab876b343e24ea613566c00058f
1/*
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
17#ifndef ANDROID_AUDIO_FAST_THREAD_STATE_H
18#define ANDROID_AUDIO_FAST_THREAD_STATE_H
19
20#include <stdint.h>
21#include <media/nbaio/NBLog.h>
22
23namespace android {
24
25// Represents a single state of a FastThread
26struct FastThreadState {
27                FastThreadState();
28    /*virtual*/ ~FastThreadState();
29
30    typedef uint32_t Command;
31    static const Command
32        INITIAL = 0,            // used only for the initial state
33        HOT_IDLE = 1,           // do nothing
34        COLD_IDLE = 2,          // wait for the futex
35        IDLE = 3,               // either HOT_IDLE or COLD_IDLE
36        EXIT = 4;               // exit from thread
37        // additional values defined per subclass
38    Command     mCommand;
39
40    int32_t*    mColdFutexAddr; // for COLD_IDLE only, pointer to the associated futex
41    unsigned    mColdGen;       // increment when COLD_IDLE is requested so it's only performed once
42
43    NBLog::Writer* mNBLogWriter; // non-blocking logger
44};  // struct FastThreadState
45
46}   // android
47
48#endif  // ANDROID_AUDIO_FAST_THREAD_STATE_H
49