Let SaturatingSemaphore::try_wait be non-const and add ready
[folly.git] / folly / SmallLocks.h
1 /*
2  * Copyright 2017 Facebook, Inc.
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 #pragma once
18
19 /*
20  * This header defines a few very small mutex types.  These are useful
21  * in highly memory-constrained environments where contention is
22  * unlikely.
23  *
24  * Note: these locks are for use when you aren't likely to contend on
25  * the critical section, or when the critical section is incredibly
26  * small.  Given that, both of the locks defined in this header are
27  * inherently unfair: that is, the longer a thread is waiting, the
28  * longer it waits between attempts to acquire, so newer waiters are
29  * more likely to get the mutex.  For the intended use-case this is
30  * fine.
31  *
32  * @author Keith Adams <kma@fb.com>
33  * @author Jordan DeLong <delong.j@fb.com>
34  */
35
36 #include <folly/MicroLock.h>
37 #include <folly/MicroSpinLock.h>
38
39 #include <folly/Portability.h>
40 #if FOLLY_X64 || FOLLY_AARCH64 || FOLLY_PPC64
41 #include <folly/PicoSpinLock.h>
42 #endif