Apollo  6.0
Open source self driving car software
multicast_notifier.h
Go to the documentation of this file.
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 
26 namespace apollo {
27 namespace cyber {
28 namespace 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 
51 };
52 
53 } // namespace transport
54 } // namespace cyber
55 } // namespace apollo
56 
57 #endif // CYBER_TRANSPORT_SHM_MULTICAST_NOTIFIER_H_
static const char * Type()
Definition: multicast_notifier.h:38
Definition: multicast_notifier.h:30
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
bool Listen(int timeout_ms, ReadableInfo *info) override
Definition: readable_info.h:32
Definition: notifier_base.h:31
#define DECLARE_SINGLETON(classname)
Definition: macros.h:52
bool Notify(const ReadableInfo &info) override