pre_release_callback.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. #pragma once
  6. #include "rocksdb/status.h"
  7. namespace ROCKSDB_NAMESPACE {
  8. class DB;
  9. class PreReleaseCallback {
  10. public:
  11. virtual ~PreReleaseCallback() {}
  12. // Will be called while on the write thread after the write to the WAL and
  13. // before the write to memtable. This is useful if any operation needs to be
  14. // done before the write gets visible to the readers, or if we want to reduce
  15. // the overhead of locking by updating something sequentially while we are on
  16. // the write thread. If the callback fails, this function returns a non-OK
  17. // status, the sequence number will not be released, and same status will be
  18. // propagated to all the writers in the write group.
  19. // seq is the sequence number that is used for this write and will be
  20. // released.
  21. // is_mem_disabled is currently used for debugging purposes to assert that
  22. // the callback is done from the right write queue.
  23. // If non-zero, log_number indicates the WAL log to which we wrote.
  24. // index >= 0 specifies the order of callback in the same write thread.
  25. // total > index specifies the total number of callbacks in the same write
  26. // thread. Together with index, could be used to reduce the redundant
  27. // operations among the callbacks.
  28. virtual Status Callback(SequenceNumber seq, bool is_mem_disabled,
  29. uint64_t log_number, size_t index, size_t total) = 0;
  30. };
  31. } // namespace ROCKSDB_NAMESPACE