Apollo 10.0
自动驾驶开放平台
multicast_notifier.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef CYBER_TRANSPORT_SHM_MULTICAST_NOTIFIER_H_
18#define CYBER_TRANSPORT_SHM_MULTICAST_NOTIFIER_H_
19
20#include <netinet/in.h>
21#include <atomic>
22
23#include "cyber/common/macros.h"
25
26namespace apollo {
27namespace cyber {
28namespace transport {
29
31 public:
32 virtual ~MulticastNotifier();
33
34 void Shutdown() override;
35 bool Notify(const ReadableInfo& info) override;
36 bool Listen(int timeout_ms, ReadableInfo* info) override;
37
38 static const char* Type() { return "multicast"; }
39
40 private:
41 bool Init();
42
43 int notify_fd_ = -1;
44 struct sockaddr_in notify_addr_;
45 int listen_fd_ = -1;
46 struct sockaddr_in listen_addr_;
47
48 std::atomic<bool> is_shutdown_ = {false};
49
50 DECLARE_SINGLETON(MulticastNotifier)
51};
52
53} // namespace transport
54} // namespace cyber
55} // namespace apollo
56
57#endif // CYBER_TRANSPORT_SHM_MULTICAST_NOTIFIER_H_
bool Notify(const ReadableInfo &info) override
bool Listen(int timeout_ms, ReadableInfo *info) override
#define DECLARE_SINGLETON(classname)
Definition macros.h:52
class register implement
Definition arena_queue.h:37