|
| 1 | +// Copyright 2022 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 | +/** |
| 16 | + * @file OneShotConnector.hpp |
| 17 | + * |
| 18 | + * This file contains class OneShotConnector implementation. |
| 19 | + */ |
| 20 | + |
| 21 | +#pragma once |
| 22 | + |
| 23 | +#include <cpp_utils/threading/task/ArgsOwnedTask.hpp> |
| 24 | + |
| 25 | +namespace eprosima { |
| 26 | +namespace utils { |
| 27 | +namespace threading { |
| 28 | + |
| 29 | +template <typename ... Args> |
| 30 | +void OneShotConnector<Args...>::execute( |
| 31 | + IManager* manager, |
| 32 | + const std::function<void(Args...)>& callback, |
| 33 | + Args... args) |
| 34 | +{ |
| 35 | + manager->execute( |
| 36 | + std::make_unique<ArgsOwnedTask<Args...>>( |
| 37 | + callback, |
| 38 | + args... |
| 39 | + ) |
| 40 | + ); |
| 41 | +} |
| 42 | + |
| 43 | +template <typename ... Args> |
| 44 | +void OneShotConnector<Args...>::execute( |
| 45 | + IManager* manager, |
| 46 | + std::function<void(Args...)>&& callback, |
| 47 | + Args... args) |
| 48 | +{ |
| 49 | + manager->execute( |
| 50 | + std::make_unique<ArgsOwnedTask<Args...>>( |
| 51 | + std::move(callback), |
| 52 | + args... |
| 53 | + ) |
| 54 | + ); |
| 55 | +} |
| 56 | + |
| 57 | +// template <typename ... Args> |
| 58 | +// void OneShotConnector<Args...>::execute( |
| 59 | +// IManager* manager, |
| 60 | +// std::function<void(Args...)> callback, |
| 61 | +// Args... args) |
| 62 | +// { |
| 63 | +// manager->execute( |
| 64 | +// std::make_unique<ArgsOwnedTask<Args...>>( |
| 65 | +// callback, |
| 66 | +// args... |
| 67 | +// ) |
| 68 | +// ); |
| 69 | +// } |
| 70 | + |
| 71 | +} /* namespace thread */ |
| 72 | +} /* namespace event */ |
| 73 | +} /* namespace eprosima */ |
0 commit comments