Loading...
Searching...
No Matches
geo_global_executor.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#pragma once
21#include <mutex>
22#include <queue>
23#include <unordered_map>
24
29
30namespace resdb {
31
33 public:
35 std::unique_ptr<TransactionManager> global_transaction_manager,
36 const ResDBConfig& config);
37 virtual ~GeoGlobalExecutor();
38 virtual void Execute(std::unique_ptr<Request> request);
39 virtual int OrderGeoRequest(std::unique_ptr<Request> request);
40
41 void Stop();
42
43 std::unique_ptr<BatchUserResponse> GetResponseMsg();
44
45 private:
46 using ExecuteMap =
47 std::map<std::pair<uint64_t, int>, std::unique_ptr<Request>>;
48
49 bool IsStop();
50 void OrderRound();
51 std::unique_ptr<Request> GetNextMap();
52 void AddData();
53
54 protected:
55 std::unique_ptr<TransactionManager> global_transaction_manager_;
58 ExecuteMap execute_map_;
59 uint64_t next_seq_ = 1;
60 int next_region_ = 1;
63 std::atomic<bool> is_stop_;
64 std::mutex mutex_;
65 std::condition_variable cv_;
69};
70} // namespace resdb
virtual void Execute(std::unique_ptr< Request > request)
std::unique_ptr< BatchUserResponse > GetResponseMsg()
LockFreeQueue< Request > order_queue_
std::condition_variable cv_
virtual int OrderGeoRequest(std::unique_ptr< Request > request)
LockFreeQueue< BatchUserResponse > resp_queue_
std::unique_ptr< TransactionManager > global_transaction_manager_
std::atomic< bool > is_stop_