Apollo 10.0
自动驾驶开放平台
choreography_context.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_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
31namespace apollo {
32namespace cyber {
33namespace scheduler {
34
36using 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_
std::shared_ptr< CRoutine > NextRoutine() override
bool Enqueue(const std::shared_ptr< CRoutine > &)
class register implement
Definition arena_queue.h:37