lock_manager.cc 1017 B

12345678910111213141516171819202122232425262728
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #include "utilities/transactions/lock/lock_manager.h"
  6. #include "utilities/transactions/lock/point/point_lock_manager.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. std::shared_ptr<LockManager> NewLockManager(PessimisticTransactionDB* db,
  9. const TransactionDBOptions& opt) {
  10. assert(db);
  11. if (opt.lock_mgr_handle) {
  12. // A custom lock manager was provided in options
  13. auto mgr = opt.lock_mgr_handle->getLockManager();
  14. return std::shared_ptr<LockManager>(opt.lock_mgr_handle, mgr);
  15. } else {
  16. if (opt.use_per_key_point_lock_mgr) {
  17. return std::make_shared<PerKeyPointLockManager>(db, opt);
  18. } else {
  19. return std::make_shared<PointLockManager>(db, opt);
  20. }
  21. }
  22. }
  23. } // namespace ROCKSDB_NAMESPACE