]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/flush_scheduler.h
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).
12 #include "util/autovector.h"
14 namespace ROCKSDB_NAMESPACE
{
16 class ColumnFamilyData
;
18 // FlushScheduler keeps track of all column families whose memtable may
19 // be full and require flushing. Unless otherwise noted, all methods on
20 // FlushScheduler should be called only with the DB mutex held or from
21 // a single-threaded recovery context.
22 class FlushScheduler
{
24 FlushScheduler() : head_(nullptr) {}
26 // May be called from multiple threads at once, but not concurrent with
27 // any other method calls on this instance
28 void ScheduleWork(ColumnFamilyData
* cfd
);
30 // Removes and returns Ref()-ed column family. Client needs to Unref().
31 // Filters column families that have been dropped.
32 ColumnFamilyData
* TakeNextColumnFamily();
34 // This can be called concurrently with ScheduleWork but it would miss all
35 // the scheduled flushes after the last synchronization. This would result
36 // into less precise enforcement of memtable sizes but should not matter much.
43 ColumnFamilyData
* column_family
;
47 std::atomic
<Node
*> head_
;
49 std::mutex checking_mutex_
;
50 std::set
<ColumnFamilyData
*> checking_set_
;
54 } // namespace ROCKSDB_NAMESPACE