/Users/deen/code/yugabyte-db/src/yb/rocksdb/db/flush_scheduler.h
Line | Count | Source |
1 | | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
2 | | // This source code is licensed under the BSD-style license found in the |
3 | | // LICENSE file in the root directory of this source tree. An additional grant |
4 | | // of patent rights can be found in the PATENTS file in the same directory. |
5 | | // |
6 | | // The following only applies to changes made to this file as part of YugaByte development. |
7 | | // |
8 | | // Portions Copyright (c) YugaByte, Inc. |
9 | | // |
10 | | // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except |
11 | | // in compliance with the License. You may obtain a copy of the License at |
12 | | // |
13 | | // http://www.apache.org/licenses/LICENSE-2.0 |
14 | | // |
15 | | // Unless required by applicable law or agreed to in writing, software distributed under the License |
16 | | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
17 | | // or implied. See the License for the specific language governing permissions and limitations |
18 | | // under the License. |
19 | | // |
20 | | |
21 | | #pragma once |
22 | | |
23 | | #include <atomic> |
24 | | #include <mutex> |
25 | | #include <set> |
26 | | |
27 | | namespace rocksdb { |
28 | | |
29 | | class ColumnFamilyData; |
30 | | |
31 | | // Unless otherwise noted, all methods on FlushScheduler should be called |
32 | | // only with the DB mutex held or from a single-threaded recovery context. |
33 | | class FlushScheduler { |
34 | | public: |
35 | 435k | FlushScheduler() : head_(nullptr) {} |
36 | | |
37 | | // May be called from multiple threads at once, but not concurrent with |
38 | | // any other method calls on this instance |
39 | | void ScheduleFlush(ColumnFamilyData* cfd); |
40 | | |
41 | | // Removes and returns Ref()-ed column family. Client needs to Unref(). |
42 | | // Filters column families that have been dropped. |
43 | | ColumnFamilyData* TakeNextColumnFamily(); |
44 | | |
45 | | bool Empty(); |
46 | | |
47 | | void Clear(); |
48 | | |
49 | | private: |
50 | | struct Node { |
51 | | ColumnFamilyData* column_family; |
52 | | Node* next; |
53 | | }; |
54 | | |
55 | | std::atomic<Node*> head_; |
56 | | #ifndef NDEBUG |
57 | | std::mutex checking_mutex_; |
58 | | std::set<ColumnFamilyData*> checking_set_; |
59 | | #endif // NDEBUG |
60 | | }; |
61 | | |
62 | | } // namespace rocksdb |