# kyotocabinet::Mutex Class Reference

Basic mutual exclusion device. More...

`#include <kcthread.h>`

List of all members.

## Public Types

enum | Type { FAST, ERRORCHECK, RECURSIVE }
| Type of the behavior for double locking. More...

## Public Member Functions

| Mutex ()
| Default constructor.
| Mutex (Type type)
| Constructor.
| ~Mutex ()
| Destructor.
void | lock ()
| Get the lock.
bool | lock_try ()
| Try to get the lock.
bool | lock_try (double sec)
| Try to get the lock.
void | unlock ()
| Release the lock.

## Friends

class | CondVar

## Detailed Description

Basic mutual exclusion device.

## Member Enumeration Documentation

enum kyotocabinet::Mutex::Type

Type of the behavior for double locking.

Enumerator:

  FAST | no operation
  ERRORCHECK | check error
  RECURSIVE | allow recursive locking

## Constructor & Destructor Documentation

kyotocabinet::Mutex::Mutex | ( |  | ) | `[explicit]`

Default constructor.

kyotocabinet::Mutex::Mutex | ( | Type | type | ) | `[explicit]`

Constructor.

Parameters:

  | type | the behavior for double locking.

kyotocabinet::Mutex::~Mutex | ( |  | ) |

Destructor.

## Member Function Documentation

void kyotocabinet::Mutex::lock | ( |  | ) |

Get the lock.

bool kyotocabinet::Mutex::lock_try | ( |  | ) |

Try to get the lock.

Returns:
  true on success, or false on failure.

bool kyotocabinet::Mutex::lock_try | ( | double | sec | ) |

Try to get the lock.

Parameters:

  | sec | the interval of the suspension in seconds.

Returns:
  true on success, or false on failure.

void kyotocabinet::Mutex::unlock | ( |  | ) |

Release the lock.