Coverage Report

Created: 2026-07-25 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/src/cpp/rtps/transport/ChannelResource.cpp
Line
Count
Source
1
// Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <rtps/transport/ChannelResource.h>
16
17
#include <utils/thread.hpp>
18
19
namespace eprosima {
20
namespace fastdds {
21
namespace rtps {
22
23
using Log = fastdds::dds::Log;
24
25
ChannelResource::ChannelResource()
26
0
    : message_buffer_(RTPSMESSAGE_DEFAULT_SIZE)
27
0
    , alive_(true)
28
0
{
29
0
    EPROSIMA_LOG_INFO(RTPS_MSG_IN, "Created with CDRMessage of size: " << message_buffer_.max_size);
30
0
}
31
32
ChannelResource::ChannelResource(
33
        ChannelResource&& channelResource)
34
0
    : message_buffer_(std::move(channelResource.message_buffer_))
35
0
    , thread_(std::move(channelResource.thread_))
36
0
{
37
0
    bool b = channelResource.alive_;
38
0
    alive_.store(b);
39
    //EPROSIMA_LOG_INFO(RTPS_MSG_IN, "Created with CDRMessage of size: " << message_buffer_.max_size);
40
    //message_buffer_ = std::move(channelResource.message_buffer_);
41
0
}
42
43
ChannelResource::ChannelResource(
44
        uint32_t rec_buffer_size)
45
0
    : message_buffer_(rec_buffer_size)
46
0
    , alive_(true)
47
0
{
48
0
    memset(message_buffer_.buffer, 0, rec_buffer_size);
49
0
    EPROSIMA_LOG_INFO(RTPS_MSG_IN, "Created with CDRMessage of size: " << message_buffer_.max_size);
50
0
}
51
52
ChannelResource::~ChannelResource()
53
0
{
54
0
    clear();
55
0
}
56
57
void ChannelResource::clear()
58
0
{
59
0
    alive_.store(false);
60
0
    if (thread_.joinable())
61
0
    {
62
0
        if (!thread_.is_calling_thread())
63
0
        {
64
            // wait for it to finish
65
0
            thread_.join();
66
0
        }
67
0
        else
68
0
        {
69
            // killing my own thread
70
0
            thread_.detach();
71
0
        }
72
0
    }
73
0
}
74
75
} // namespace rtps
76
} // namespace fastdds
77
} // namespace eprosima