Public Member Functions
ibis::util::sharedInt32 Class Reference

A shared integer class. More...

#include <util.h>

List of all members.

Public Member Functions

uint32_t operator() () const
 Read the current value.
uint32_t operator++ ()
 Increment operator.
void operator+= (const uint32_t rhs)
 In-place addition operator.
uint32_t operator-- ()
 Decrement operator.
void operator-= (const uint32_t rhs)
 In-place subtraction operator.
void swap (sharedInt32 &rhs)
 Swap the contents of two integer variables.

Detailed Description

A shared integer class.

Multiply threads may safely perform different operations on this integer at the same time. It serializes the operations by using the atomic operations provided by GCC extension. The availability of automic operations is indicated by whether or not the compiler macro HAVE_GCC_ATOMIC32 is defined. If the atomic extension is not available, it falls back on the mutual exclusion lock provided by pthread library.

Note:
The overhead of using mutual exclusion lock is large. In one test that acquires and release three locks a million time each, using the locks took about 10 seconds, while using the atomic extension to perform the same arithmetic operations took about 0.1 seconds.

The documentation for this class was generated from the following file:

Make It A Bit Faster
Contact us
Disclaimers
FastBit source code
FastBit mailing list archive