/usr/include/kvutils/kvu_locks.h is in libkvutils-dev 2.8.1-5build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | // -*- mode: C++; -*-
#ifndef INCLUDED_KVU_LOCKS_H
#define INCLUDED_KVU_LOCKS_H
#include <pthread.h>
/**
* Atomic access to single integer values. Implementation
* may be based on direct atomic operations or traditional
* locking, depending on the underlying platform.
*
* On supported platforms, atomicity is guaranteed for
* both single- and multiprocessor concurrency. Ordering of
* concurrent reads and writes is however not guaranteed.
*
* Note! Atomic test-and-modify operations are not provided.
*/
class ATOMIC_INTEGER {
public:
/**
* Returns the stored integer value.
*
* Non-blocking.
*/
int get(void) const;
/**
* Sets the integer value to 'value'.
*
* Non-blocking. Atomic on most platforms.
*
* Atomic without limitations on most platforms. On some
* platforms (e.g. sparc64 and armv6), writes from multiple
* threads are unsafe.
*/
void set(int value);
ATOMIC_INTEGER(int value = 0);
~ATOMIC_INTEGER(void);
private:
volatile int value_rep;
ATOMIC_INTEGER& operator=(const ATOMIC_INTEGER& v);
ATOMIC_INTEGER(const ATOMIC_INTEGER& v);
};
/**
* A simple guarded lock wrapper for pthread_mutex_lock
* and pthread_mutex_unlock. Lock is acquired
* upon object creating and released during destruction.
*/
class KVU_GUARD_LOCK {
public:
KVU_GUARD_LOCK(pthread_mutex_t* lock_arg);
~KVU_GUARD_LOCK(void);
private:
pthread_mutex_t* lock_repp;
KVU_GUARD_LOCK(void) {}
KVU_GUARD_LOCK(const KVU_GUARD_LOCK&) {}
KVU_GUARD_LOCK& operator=(const KVU_GUARD_LOCK&) { return *this; }
};
#endif
|