X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FFile.h;h=71fcc03361de7e1da64d7a2d4a947c79e66a461d;hp=e990c91bfc14efcd0274dc01c6c84edf63237315;hb=d1028d196481191a6e3adf1b081f736b89c52cfa;hpb=d6e5191558bf975609761af76a173fa3e197eee3 diff --git a/folly/File.h b/folly/File.h index e990c91b..71fcc033 100644 --- a/folly/File.h +++ b/folly/File.h @@ -20,6 +20,7 @@ #include #include #include +#include namespace folly { @@ -92,7 +93,26 @@ class File { File(File&&); File& operator=(File&&); + // FLOCK (INTERPROCESS) LOCKS + // + // NOTE THAT THESE LOCKS ARE flock() LOCKS. That is, they may only be used + // for inter-process synchronization -- an attempt to acquire a second lock + // on the same file descriptor from the same process may succeed. Attempting + // to acquire a second lock on a different file descriptor for the same file + // should fail, but some systems might implement flock() using fcntl() locks, + // in which case it will succeed. + void lock(); + bool try_lock(); + void unlock(); + + void lock_shared(); + bool try_lock_shared(); + void unlock_shared(); + private: + void doLock(int op); + bool doTryLock(int op); + // unique File(const File&) = delete; File& operator=(const File&) = delete; @@ -103,6 +123,7 @@ class File { void swap(File& a, File& b); + } // namespace folly #endif /* FOLLY_FILE_H_ */