1 #include "android-base/thread_annotations.h" 2 3 // Encapsulates advisory file lock for a given field descriptor 4 class CAPABILITY("FileLock") FileLock { 5 public: 6 FileLock(int fd); 7 ~FileLock() = default; 8 9 // Acquires advisory file lock. This will block only if called from different processes. 10 int lock() ACQUIRE(); 11 // Releases advisory file lock. 12 int unlock() RELEASE(); 13 14 private: 15 int fd_; 16 };