Apollo  6.0
Open source self driving car software
player.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_TOOLS_CYBER_RECORDER_PLAYER_PLAYER_H_
18 #define CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAYER_H_
19 
20 #include <atomic>
21 #include <memory>
22 #include <thread>
23 
28 
29 namespace apollo {
30 namespace cyber {
31 namespace record {
32 
33 class Player {
34  public:
35  using ConsumerPtr = std::unique_ptr<PlayTaskConsumer>;
36  using ProducerPtr = std::unique_ptr<PlayTaskProducer>;
37  using TaskBufferPtr = std::shared_ptr<PlayTaskBuffer>;
38 
39  explicit Player(const PlayParam& play_param);
40  virtual ~Player();
41 
42  bool Init();
43  bool Start();
44  bool Stop();
45 
46  private:
47  void ThreadFunc_Term();
48 
49  private:
50  std::atomic<bool> is_initialized_ = {false};
51  std::atomic<bool> is_stopped_ = {false};
52  std::atomic<bool> is_paused_ = {false};
53  std::atomic<bool> is_playonce_ = {false};
54  ConsumerPtr consumer_;
55  ProducerPtr producer_;
56  TaskBufferPtr task_buffer_;
57  std::shared_ptr<std::thread> term_thread_ = nullptr;
58  static const uint64_t kSleepIntervalMiliSec;
59 };
60 
61 } // namespace record
62 } // namespace cyber
63 } // namespace apollo
64 
65 #endif // CYBER_TOOLS_CYBER_RECORDER_PLAYER_PLAYER_H_
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Player(const PlayParam &play_param)
Definition: play_param.h:29
std::unique_ptr< PlayTaskConsumer > ConsumerPtr
Definition: player.h:35
std::shared_ptr< PlayTaskBuffer > TaskBufferPtr
Definition: player.h:37
Definition: player.h:33
std::unique_ptr< PlayTaskProducer > ProducerPtr
Definition: player.h:36