X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=cds%2Fsync%2Flock_array.h;h=1ad3360278fb650078482630b67cd7cf9aef54dc;hb=df4d0c52b3eff17a49505093870a37ea8c9d565d;hp=60044917b0b6c20d7824a48f32ccf9ec4fe42801;hpb=36347e82740e7f7c35d198b20b470a85216a4264;p=libcds.git
diff --git a/cds/sync/lock_array.h b/cds/sync/lock_array.h
index 60044917..1ad33602 100644
--- a/cds/sync/lock_array.h
+++ b/cds/sync/lock_array.h
@@ -1,4 +1,32 @@
-//$$CDS-header$$
+/*
+ This file is a part of libcds - Concurrent Data Structures library
+
+ (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
+
+ Source code repo: http://github.com/khizmax/libcds/
+ Download: http://sourceforge.net/projects/libcds/files/
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
#ifndef CDSLIB_SYNC_LOCK_ARRAY_H
#define CDSLIB_SYNC_LOCK_ARRAY_H
@@ -9,7 +37,7 @@
namespace cds { namespace sync {
- /// Trivial lock \ref array selection policy
+ /// Trivial lock \ref lock_array selection policy
struct trivial_select_policy
{
/// Returns \p nWhat
@@ -28,7 +56,7 @@ namespace cds { namespace sync {
}
};
- /// The lock \ref array cell selection policy "division by modulo"
+ /// The lock \ref lock_array cell selection policy "division by modulo"
struct mod_select_policy
{
/// Returns nWhat % nCapacity
@@ -44,7 +72,7 @@ namespace cds { namespace sync {
}
};
- /// The lock \ref array cell selection policy "division by modulo of power of 2"
+ /// The lock \ref lock_array cell selection policy "division by modulo of power of 2"
/**
This policy may be used if the size of lock array is equal to power of two.
*/
@@ -204,15 +232,15 @@ namespace cds { namespace sync {
/// Locks a lock at cell \p hint
/**
To define real array's cell which should be locked, \ref select_cell_policy is used.
- The target cell is a result of select_cell_policy( hint, size() ).
+ The target cell is a result of select_cell_policy( hint, size()).
Returns the index of locked lock.
*/
template
size_t lock( Q const& hint )
{
- size_t nCell = m_SelectCellPolicy( hint, size() );
- assert( nCell < size() );
+ size_t nCell = m_SelectCellPolicy( hint, size());
+ assert( nCell < size());
m_arrLocks[nCell].lock();
return nCell;
}
@@ -220,16 +248,16 @@ namespace cds { namespace sync {
/// Try lock a lock at cell \p hint
/**
To define real array's cell which should be locked, \ref select_cell_policy is used.
- The target cell is a result of select_cell_policy( hint, size() ).
+ The target cell is a result of select_cell_policy( hint, size()).
Returns the index of locked lock if success, \ref c_nUnspecifiedCell constant otherwise.
*/
template
size_t try_lock( Q const& hint )
{
- size_t nCell = m_SelectCellPolicy( hint, size() );
- assert( nCell < size() );
- if ( m_arrLocks[nCell].try_lock() )
+ size_t nCell = m_SelectCellPolicy( hint, size());
+ assert( nCell < size());
+ if ( m_arrLocks[nCell].try_lock())
return nCell;
return c_nUnspecifiedCell;
}
@@ -237,7 +265,7 @@ namespace cds { namespace sync {
/// Unlock the lock specified by index \p nCell
void unlock( size_t nCell )
{
- assert( nCell < size() );
+ assert( nCell < size());
m_arrLocks[nCell].unlock();
}
@@ -263,7 +291,7 @@ namespace cds { namespace sync {
*/
lock_type& at( size_t nCell ) const
{
- assert( nCell < size() );
+ assert( nCell < size());
return m_arrLocks[ nCell ];
}
@@ -297,7 +325,7 @@ namespace std {
template
unique_lock( lock_array_type& arrLocks, Q const& hint )
: m_arrLocks( arrLocks )
- , m_nLockGuarded( arrLocks.lock( hint ) )
+ , m_nLockGuarded( arrLocks.lock( hint ))
{}
/// Locks all from \p arrLocks array