~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/ext/boost/smart_ptr/detail/spinlock_pt.hpp

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
 
2
#define BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED
 
3
 
 
4
// MS compatible compilers support #pragma once
 
5
 
 
6
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
 
7
# pragma once
 
8
#endif
 
9
 
 
10
//
 
11
//  Copyright (c) 2008 Peter Dimov
 
12
//
 
13
//  Distributed under the Boost Software License, Version 1.0.
 
14
//  See accompanying file LICENSE_1_0.txt or copy at
 
15
//  http://www.boost.org/LICENSE_1_0.txt)
 
16
//
 
17
 
 
18
#include <pthread.h>
 
19
 
 
20
namespace boost
 
21
{
 
22
 
 
23
namespace detail
 
24
{
 
25
 
 
26
class spinlock
 
27
{
 
28
public:
 
29
 
 
30
    pthread_mutex_t v_;
 
31
 
 
32
public:
 
33
 
 
34
    bool try_lock()
 
35
    {
 
36
        return pthread_mutex_trylock( &v_ ) == 0;
 
37
    }
 
38
 
 
39
    void lock()
 
40
    {
 
41
        pthread_mutex_lock( &v_ );
 
42
    }
 
43
 
 
44
    void unlock()
 
45
    {
 
46
        pthread_mutex_unlock( &v_ );
 
47
    }
 
48
 
 
49
public:
 
50
 
 
51
    class scoped_lock
 
52
    {
 
53
    private:
 
54
 
 
55
        spinlock & sp_;
 
56
 
 
57
        scoped_lock( scoped_lock const & );
 
58
        scoped_lock & operator=( scoped_lock const & );
 
59
 
 
60
    public:
 
61
 
 
62
        explicit scoped_lock( spinlock & sp ): sp_( sp )
 
63
        {
 
64
            sp.lock();
 
65
        }
 
66
 
 
67
        ~scoped_lock()
 
68
        {
 
69
            sp_.unlock();
 
70
        }
 
71
    };
 
72
};
 
73
 
 
74
} // namespace detail
 
75
} // namespace boost
 
76
 
 
77
#define BOOST_DETAIL_SPINLOCK_INIT { PTHREAD_MUTEX_INITIALIZER }
 
78
 
 
79
#endif // #ifndef BOOST_SMART_PTR_DETAIL_SPINLOCK_PT_HPP_INCLUDED