Program Listing for File ResourceEvent.h
↰ Return to documentation for file (/tmp/ws/src/fastrtps/include/fastdds/rtps/resources/ResourceEvent.h
)
// Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _FASTDDS_RTPS_RESOURCES_RESOURCEEVENT_H_
#define _FASTDDS_RTPS_RESOURCES_RESOURCEEVENT_H_
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#include <fastrtps/utils/TimedMutex.hpp>
#include <fastrtps/utils/TimedConditionVariable.hpp>
#include <thread>
#include <atomic>
#include <vector>
namespace eprosima {
namespace fastrtps {
namespace rtps {
class TimedEventImpl;
class ResourceEvent
{
public:
ResourceEvent() = default;
~ResourceEvent();
void init_thread();
void stop_thread();
void register_timer(
TimedEventImpl* event);
void unregister_timer(
TimedEventImpl* event);
void notify(
TimedEventImpl* event);
void notify(
TimedEventImpl* event,
const std::chrono::steady_clock::time_point& timeout);
private:
std::atomic<bool> stop_{ false };
TimedMutex mutex_;
TimedConditionVariable cv_manipulation_;
bool allow_vector_manipulation_ = true;
TimedConditionVariable cv_;
size_t timers_count_ = 0;
std::vector<TimedEventImpl*> pending_timers_;
std::vector<TimedEventImpl*> active_timers_;
std::atomic<bool> skip_checking_active_timers_;
std::chrono::steady_clock::time_point current_time_;
std::thread thread_;
bool register_timer_nts(
TimedEventImpl* event);
void event_service();
void sort_timers();
void update_current_time();
void do_timer_actions();
void resize_collections()
{
pending_timers_.reserve(timers_count_);
active_timers_.reserve(timers_count_);
}
};
} /* namespace rtps */
} /* namespace fastrtps */
} /* namespace eprosima */
#endif //DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
#endif //_FASTDDS_RTPS_RESOURCES_RESOURCEEVENT_H_