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
27
#include "
cyber/base/atomic_rw_lock.h
"
28
#include "
cyber/croutine/croutine.h
"
29
#include "
cyber/scheduler/processor_context.h
"
30
31
namespace
apollo
{
32
namespace
cyber {
33
namespace
scheduler {
34
35
using
apollo::cyber::base::AtomicRWLock
;
36
using
croutine::CRoutine;
37
38
class
ChoreographyContext
:
public
ProcessorContext
{
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_
atomic_rw_lock.h
apollo::cyber::base::AtomicRWLock
Definition
atomic_rw_lock.h:36
apollo::cyber::scheduler::ChoreographyContext
Definition
choreography_context.h:38
apollo::cyber::scheduler::ChoreographyContext::RemoveCRoutine
bool RemoveCRoutine(uint64_t crid)
Definition
choreography_context.cc:85
apollo::cyber::scheduler::ChoreographyContext::NextRoutine
std::shared_ptr< CRoutine > NextRoutine() override
Definition
choreography_context.cc:35
apollo::cyber::scheduler::ChoreographyContext::Enqueue
bool Enqueue(const std::shared_ptr< CRoutine > &)
Definition
choreography_context.cc:55
apollo::cyber::scheduler::ChoreographyContext::Notify
void Notify()
Definition
choreography_context.cc:61
apollo::cyber::scheduler::ChoreographyContext::Wait
void Wait() override
Definition
choreography_context.cc:68
apollo::cyber::scheduler::ChoreographyContext::Shutdown
void Shutdown() override
Definition
choreography_context.cc:77
apollo::cyber::scheduler::ProcessorContext
Definition
processor_context.h:33
croutine.h
apollo
class register implement
Definition
arena_queue.h:37
processor_context.h
cyber
scheduler
policy
choreography_context.h