---
name: "ACE_Lock"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Lock"
---

# ACE\_Lock(3)

This is the abstract base class that contains the uniform locking API that is supported by all the ACE synchronization mechanisms.

## NAME

ACE\_Lock -  This is the abstract base class that contains the uniform locking API that is supported by all the ACE synchronization mechanisms.

## SYNOPSIS

```
#include <ace/Synch.h>
class ACE_Lock
{
  public:
    ACE_Lock (void);
    virtual ~ACE_Lock (void);
    virtual int remove (void) = 0;
    virtual int acquire (void) = 0;
    virtual int tryacquire (void) = 0;
    virtual int release (void) = 0;
    virtual int acquire_read (void) = 0;
    virtual int acquire_write (void) = 0;
    virtual int tryacquire_read (void) = 0;
    virtual int tryacquire_write (void) = 0;
};
```

## DESCRIPTION

Wrappers for various synchronization routines.

## PUBLIC MEMBERS

```
ACE_Lock (void);
```

CE needs a default ctor here.

```
virtual ~ACE_Lock (void);
```

Noop virtual destructor

```
virtual int remove (void) = 0;
```

Explicitly destroy the lock.  Note that only one thread should call this method since it doesn't protect against race conditions.

```
virtual int acquire (void) = 0;
```

Block the thread until the lock is acquired.  Returns -1 on failure.

```
virtual int tryacquire (void) = 0;
```

Conditionally acquire the lock (i.e., won't block).  Returns -1 on failure.  If we "failed" because someone else already had the lock, errno is set to EBUSY.

```
virtual int release (void) = 0;
```

Release the lock.  Returns -1 on failure.

```
virtual int acquire_read (void) = 0;
```

Block until the thread acquires a read lock.  If the locking mechanism doesn't support read locks then this just calls acquire.  Returns -1 on failure.

```
virtual int acquire_write (void) = 0;
```

Block until the thread acquires a write lock.  If the locking mechanism doesn't support read locks then this just calls acquire.  Returns -1 on failure.

```
virtual int tryacquire_read (void) = 0;
```

Conditionally acquire a read lock.  If the locking mechanism doesn't support read locks then this just calls acquire. Returns -1 on failure.  If we "failed" because someone else already had the lock, errno is set to EBUSY.

```
virtual int tryacquire_write (void) = 0;
```

Conditionally acquire a write lock.  If the locking mechanism doesn't support read locks then this just calls acquire. Returns -1 on failure.  If we "failed" because someone else already had the lock, errno is set to EBUSY.

## AUTHOR

Doug Schmidt

## LIBRARY

ace
