summaryrefslogtreecommitdiff
path: root/libhwjpeg/include/FileLock.h
blob: b308aa7d92c79fa608a783e3e53cf479d6b1a4b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "android-base/thread_annotations.h"

// Encapsulates advisory file lock for a given field descriptor
class CAPABILITY("mutex") FileLock {
public:
    FileLock(int fd);
    ~FileLock() = default;

    // Acquires advisory file lock. This will block.
    int lock() ACQUIRE();
    // Releases advisory file lock.
    int unlock() RELEASE();

private:
    int fd_;
};