Coverage Report

Created: 2026-03-12 16:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/util/uuid_generator.h
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <boost/uuid/uuid.hpp>
21
#include <boost/uuid/uuid_generators.hpp>
22
#include <boost/uuid/uuid_io.hpp>
23
#include <mutex>
24
25
namespace doris {
26
27
class UUIDGenerator {
28
public:
29
63.0M
    boost::uuids::uuid next_uuid() {
30
63.0M
        std::lock_guard<std::mutex> lock(_uuid_gen_lock);
31
63.0M
        return _boost_uuid_generator();
32
63.0M
    }
33
34
63.0M
    static UUIDGenerator* instance() {
35
63.0M
        static UUIDGenerator generator;
36
63.0M
        return &generator;
37
63.0M
    }
38
39
private:
40
    boost::uuids::basic_random_generator<boost::mt19937> _boost_uuid_generator;
41
    std::mutex _uuid_gen_lock;
42
};
43
44
} // namespace doris