blob: 20bf81cb0012b66a42c645102f5c21c4700ce38c [file] [log] [blame]
Ian Rogers81d425b2012-09-27 16:03:43 -07001/*
2 * Copyright (C) 2012 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#include "locks.h"
18
19#include "mutex.h"
20
21namespace art {
22
23ReaderWriterMutex* Locks::mutator_lock_ = NULL;
24Mutex* Locks::thread_list_lock_ = NULL;
25Mutex* Locks::classlinker_classes_lock_ = NULL;
26ReaderWriterMutex* Locks::heap_bitmap_lock_ = NULL;
27Mutex* Locks::abort_lock_ = NULL;
28Mutex* Locks::logging_lock_ = NULL;
29Mutex* Locks::unexpected_signal_lock_ = NULL;
30Mutex* Locks::thread_suspend_count_lock_ = NULL;
31
32void Locks::Init() {
33 if (logging_lock_ != NULL) {
34 // Already initialized.
35 DCHECK(mutator_lock_ != NULL);
36 DCHECK(thread_list_lock_ != NULL);
37 DCHECK(classlinker_classes_lock_ != NULL);
38 DCHECK(heap_bitmap_lock_ != NULL);
39 DCHECK(abort_lock_ != NULL);
40 DCHECK(logging_lock_ != NULL);
41 DCHECK(unexpected_signal_lock_ != NULL);
42 DCHECK(thread_suspend_count_lock_ != NULL);
43 } else {
44 logging_lock_ = new Mutex("logging lock", kLoggingLock, true);
45 abort_lock_ = new Mutex("abort lock", kAbortLock, true);
46 DCHECK(mutator_lock_ == NULL);
47 mutator_lock_ = new ReaderWriterMutex("mutator lock", kMutatorLock);
48 DCHECK(thread_list_lock_ == NULL);
49 thread_list_lock_ = new Mutex("thread list lock", kThreadListLock);
50 DCHECK(classlinker_classes_lock_ == NULL);
51 classlinker_classes_lock_ = new Mutex("ClassLinker classes lock", kClassLinkerClassesLock);
52 DCHECK(heap_bitmap_lock_ == NULL);
53 heap_bitmap_lock_ = new ReaderWriterMutex("heap bitmap lock", kHeapBitmapLock);
54 DCHECK(unexpected_signal_lock_ == NULL);
55 unexpected_signal_lock_ = new Mutex("unexpected signal lock", kUnexpectedSignalLock, true);
56 DCHECK(thread_suspend_count_lock_ == NULL);
57 thread_suspend_count_lock_ = new Mutex("thread suspend count lock", kThreadSuspendCountLock);
58 }
59}
60
61} // namespace art