Apollo  6.0
Open source self driving car software
choreography_context.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_SCHEDULER_POLICY_CHOREOGRAPHY_CONTEXT_H_
18 #define CYBER_SCHEDULER_POLICY_CHOREOGRAPHY_CONTEXT_H_
19 
20 #include <functional>
21 #include <map>
22 #include <memory>
23 #include <mutex>
24 #include <string>
25 #include <unordered_map>
26 
30 
31 namespace apollo {
32 namespace cyber {
33 namespace scheduler {
34 
36 using croutine::CRoutine;
37 
39  public:
40  bool RemoveCRoutine(uint64_t crid);
41  std::shared_ptr<CRoutine> NextRoutine() override;
42 
43  bool Enqueue(const std::shared_ptr<CRoutine>&);
44  void Notify();
45  void Wait() override;
46  void Shutdown() override;
47 
48  private:
49  std::mutex mtx_wq_;
50  std::condition_variable cv_wq_;
51  int notify = 0;
52 
53  AtomicRWLock rq_lk_;
54  std::multimap<uint32_t, std::shared_ptr<CRoutine>, std::greater<uint32_t>>
55  cr_queue_;
56 };
57 
58 } // namespace scheduler
59 } // namespace cyber
60 } // namespace apollo
61 
62 #endif // CYBER_SCHEDULER_POLICY_CHOREOGRAPHY_CONTEXT_H_
Definition: processor_context.h:33
bool Enqueue(const std::shared_ptr< CRoutine > &)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
std::shared_ptr< CRoutine > NextRoutine() override
Definition: atomic_rw_lock.h:36
Definition: choreography_context.h:38