proxygen
FileTestLockHelper.cpp File Reference
#include <glog/logging.h>
#include <folly/File.h>
#include <folly/portability/GFlags.h>

Go to the source code of this file.

Functions

 DEFINE_bool (s, false,"get shared lock")
 
 DEFINE_bool (x, false,"get exclusive lock")
 
int main (int argc, char *argv[])
 

Function Documentation

DEFINE_bool ( s  ,
false  ,
"get shared lock"   
)
DEFINE_bool ( x  ,
false  ,
"get exclusive lock"   
)
int main ( int  argc,
char *  argv[] 
)

Definition at line 25 of file FileTestLockHelper.cpp.

References f, folly::File::try_lock(), and folly::File::try_lock_shared().

25  {
26  gflags::ParseCommandLineFlags(&argc, &argv, true);
27  google::InitGoogleLogging(argv[0]);
28  CHECK_EQ(FLAGS_s + FLAGS_x, 1)
29  << "exactly one of -s and -x must be specified";
30  CHECK_EQ(argc, 2);
31  folly::File f(argv[1], O_RDWR);
32  bool r;
33  if (FLAGS_s) {
34  r = f.try_lock_shared();
35  } else {
36  r = f.try_lock();
37  }
38  return r ? 0 : 42;
39 }
auto f
char ** argv