Apollo
10.0
自动驾驶开放平台
timer_bucket.h
浏览该文件的文档.
1
/******************************************************************************
2
* Copyright 2019 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_TIMER_TIMER_BUCKET_H_
18
#define CYBER_TIMER_TIMER_BUCKET_H_
19
20
#include <list>
21
#include <memory>
22
#include <mutex>
23
24
#include "
cyber/timer/timer_task.h
"
25
26
namespace
apollo
{
27
namespace
cyber {
28
29
class
TimerBucket
{
30
public
:
31
void
AddTask
(
const
std::shared_ptr<TimerTask>& task) {
32
std::lock_guard<std::mutex> lock(mutex_);
33
task_list_.push_back(task);
34
}
35
36
std::mutex&
mutex
() {
return
mutex_; }
37
std::list<std::weak_ptr<TimerTask>>&
task_list
() {
return
task_list_; }
38
39
private
:
40
std::mutex mutex_;
41
std::list<std::weak_ptr<TimerTask>> task_list_;
42
};
43
44
}
// namespace cyber
45
}
// namespace apollo
46
47
#endif
// CYBER_TIMER_TIMER_BUCKET_H_
apollo::cyber::TimerBucket
Definition
timer_bucket.h:29
apollo::cyber::TimerBucket::AddTask
void AddTask(const std::shared_ptr< TimerTask > &task)
Definition
timer_bucket.h:31
apollo::cyber::TimerBucket::mutex
std::mutex & mutex()
Definition
timer_bucket.h:36
apollo::cyber::TimerBucket::task_list
std::list< std::weak_ptr< TimerTask > > & task_list()
Definition
timer_bucket.h:37
apollo
class register implement
Definition
arena_queue.h:37
timer_task.h
cyber
timer
timer_bucket.h