blob: 28f889ae7996f7b835a7526a104d03370072ae70 [file] [log] [blame]
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -04001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
Konrad Grochowski9be4e682013-06-22 22:03:31 +020020#include <thrift/thrift-config.h>
21
Roger Meier4285ba22013-06-10 21:17:23 +020022#include <thrift/concurrency/Mutex.h>
23#include <thrift/concurrency/Util.h>
Carl Yeksigian7cb7fc82013-06-07 07:33:01 -040024
25#include <cassert>
26#include <chrono>
27#include <mutex>
28
29namespace apache { namespace thrift { namespace concurrency {
30
31/**
32 * Implementation of Mutex class using C++11 std::timed_mutex
33 *
34 * @version $Id:$
35 */
36class Mutex::impl : public std::timed_mutex {
37};
38
39Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {}
40
41void* Mutex::getUnderlyingImpl() const { return impl_.get(); }
42
43void Mutex::lock() const { impl_->lock(); }
44
45bool Mutex::trylock() const { return impl_->try_lock(); }
46
47bool Mutex::timedlock(int64_t ms) const { return impl_->try_lock_for(std::chrono::milliseconds(ms)); }
48
49void Mutex::unlock() const { impl_->unlock(); }
50
51void Mutex::DEFAULT_INITIALIZER(void* arg) {
52}
53
54}}} // apache::thrift::concurrency
55