blob: 2277f6158dc50c310b3c548338c0104b88d3021c [file] [log] [blame]
Roger Meier3faaedf2011-10-02 10:51:45 +00001/*
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
20#ifdef HAVE_CONFIG_H
21#include <config.h>
22#endif
23#include "Mutex.h"
24#include "Util.h"
25
26#include <cassert>
27#include <boost/thread.hpp>
28#include <boost/date_time/posix_time/posix_time.hpp>
29#include <boost/interprocess/sync/interprocess_mutex.hpp>
30
31using namespace boost::interprocess;
32
33namespace apache { namespace thrift { namespace concurrency {
34
35/**
36 * Implementation of Mutex class using boost interprocess mutex
37 *
38 * @version $Id:$
39 */
40class Mutex::impl : public interprocess_mutex {
41};
42
43Mutex::Mutex(Initializer init) : impl_(new Mutex::impl()) {}
44
45void* Mutex::getUnderlyingImpl() const { return impl_.get(); }
46
47void Mutex::lock() const { impl_->lock(); }
48
49bool Mutex::trylock() const { return impl_->try_lock(); }
50
51bool Mutex::timedlock(int64_t ms) const { return impl_->timed_lock(boost::get_system_time()+boost::posix_time::milliseconds(ms)); }
52
53void Mutex::unlock() const { impl_->unlock(); }
54
55void Mutex::DEFAULT_INITIALIZER(void* arg) {
56}
57
58}}} // apache::thrift::concurrency
59