Skip to content

Commit 18c4be5

Browse files
committed
Add <mstd_mutex>
Add add-standard-as-possible version of C++11 <mutex>. A lot of the stuff in there is generic, but the actual mutex classes and call_once need to interface with the OS. For those, they're not available in ARMC5 or IAR; retargetting would be necessary for ARMC6 and GCC, and I've yet to investigate how whether that's possible. So for now I'm using local implementations. Although `Mutex` in principle could support `timed_mutex` and `recursive_timed_mutex`, we don't have `chrono` for the time parameters, so hold off for now. For the generic stuff like mstd::unique_lock, they are aliased to std::unique_lock where possible.
1 parent 2b8af90 commit 18c4be5

File tree

3 files changed

+529
-0
lines changed

3 files changed

+529
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2019 ARM Limited
3+
* SPDX-License-Identifier: Apache-2.0
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#ifndef __mutex
18+
#define __mutex
19+
20+
// Just go straight to the main file - we also need IAR implementation, so do it there
21+
#include <mstd_mutex>
22+
23+
// And then pull it all into our std
24+
namespace std {
25+
using mstd::defer_lock;
26+
using mstd::defer_lock_t;
27+
using mstd::try_to_lock;
28+
using mstd::try_to_lock_t;
29+
using mstd::adopt_lock;
30+
using mstd::adopt_lock_t;
31+
32+
using mstd::lock_guard;
33+
using mstd::unique_lock;
34+
using mstd::scoped_lock;
35+
using mstd::try_lock;
36+
using mstd::lock;
37+
38+
using mstd::once_flag;
39+
using mstd::call_once;
40+
41+
using mstd::mutex;
42+
using mstd::recursive_mutex;
43+
}
44+
45+
#endif /* __mutex */

0 commit comments

Comments
 (0)