NSTimer的精确度
1、iOS中一般UI上面常用两种定时器 NSTimer和CADisplayLink,那么它们分别的精确度是如何呢?
CADisplayLink 是用于帧刷新定时器,也就是和界面的刷新率保持一致,理想情况下FPS为60,并尽力保持60
NSTimer是否可以比CADisplayLink更加精确呢,最精确能下面的间隔是多少呢?NSTimer和CADisplayLink都作为一种事件加入到NSRunloop的事件源中,
NSRunloop不断循环,判断是否应该触发这一类事件,如下面所示,NSRunloop包涵下面这些不同的事件:
typedef CF_OPTIONS(CFOptionFlags, CFRunLoopActivity) {
kCFRunLoopEntry = (1UL << 0), // 即将进入Loop
kCFRunLoopBeforeTimers = (1UL << 1), // 即将处理 Timer
kCFRunLoopBeforeSources = (1UL << 2), // 即将处理 Source
kCFRunLoopBeforeWaiting = (1UL << 5), // 即将进入休眠
kCFRunLoopAfterWaiting = (1UL << 6), // 刚从休眠中唤醒
kCFRunLoopExit = (1UL << 7), // 即将退出Loop
};
可以看出,如果想让CADisplayLink正常工作,NSRunloop至少每秒循环60次,也就是至多17ms,那么NSRunloop每秒最多循环多少次呢?
2、NSRunloop每秒循环多少次
通过注册一个观察者到主线程中,观察每一种事件执行的log,来看看NSRunloop的执行情况
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch. CFRunLoopObserverRef observer = CFRunLoopObserverCreateWithHandler(NULL, (kCFRunLoopAllActivities), YES, 0, ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity)
{
static unsigned long count = 0; if(activity & kCFRunLoopEntry)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopEntry");
}
else if(activity & kCFRunLoopBeforeTimers)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopBeforeTimers");
}
else if(activity & kCFRunLoopBeforeSources)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopBeforeSources");
}
else if(activity & kCFRunLoopBeforeWaiting)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopBeforeWaiting");
}
else if(activity & kCFRunLoopAfterWaiting)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopAfterWaiting");
}
else if(activity & kCFRunLoopExit)
{
NSLog(@"activity %lu: %@", ++count, @"kCFRunLoopExit");
}
});
CFRunLoopAddObserver(CFRunLoopGetMain(), observer, kCFRunLoopCommonModes); return YES;
}
这里打印出每一类的事件,同时需要加上两类定时器到主线程中
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. NSTimer *timer = [NSTimer timerWithTimeInterval:0.001 repeats:YES block:^(NSTimer * _Nonnull timer) { static int timerCount = 0;
//do nothing
NSLog(@"timer do nothing, timerCount = %d", timerCount++);
}]; [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes]; CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(update:)];
[link addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; } - (void)update:(id)sender
{
static int linkCount = 0;
NSLog(@"link do nothing, linkCount = %d", linkCount++);
}
可以观察出每一类事件执行的情况,测试是在iphone5s, ios10.2的系统上
输出:
NSRunloop:
2017-03-18 13:01:54.145100 NSTimerTest[1121:267663] activity 20: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.148893 NSTimerTest[1121:267663] activity 24: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.150659 NSTimerTest[1121:267663] activity 28: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.153758 NSTimerTest[1121:267663] activity 32: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.155796 NSTimerTest[1121:267663] activity 36: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.158515 NSTimerTest[1121:267663] activity 40: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.160481 NSTimerTest[1121:267663] activity 44: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.162514 NSTimerTest[1121:267663] activity 48: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.165265 NSTimerTest[1121:267663] activity 52: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.169531 NSTimerTest[1121:267663] activity 56: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.229129 NSTimerTest[1121:267663] activity 74: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.232630 NSTimerTest[1121:267663] activity 78: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.233628 NSTimerTest[1121:267663] activity 82: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.235007 NSTimerTest[1121:267663] activity 86: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.236381 NSTimerTest[1121:267663] activity 90: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.237788 NSTimerTest[1121:267663] activity 94: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.238881 NSTimerTest[1121:267663] activity 98: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.239719 NSTimerTest[1121:267663] activity 102: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.240767 NSTimerTest[1121:267663] activity 106: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.241759 NSTimerTest[1121:267663] activity 110: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.242658 NSTimerTest[1121:267663] activity 114: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.243716 NSTimerTest[1121:267663] activity 118: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.244833 NSTimerTest[1121:267663] activity 122: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.245719 NSTimerTest[1121:267663] activity 126: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.247445 NSTimerTest[1121:267663] activity 130: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.248342 NSTimerTest[1121:267663] activity 134: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.250020 NSTimerTest[1121:267663] activity 138: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.251359 NSTimerTest[1121:267663] activity 142: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.252876 NSTimerTest[1121:267663] activity 146: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.254850 NSTimerTest[1121:267663] activity 150: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.256126 NSTimerTest[1121:267663] activity 154: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.257336 NSTimerTest[1121:267663] activity 158: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.258301 NSTimerTest[1121:267663] activity 162: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.259885 NSTimerTest[1121:267663] activity 166: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.261638 NSTimerTest[1121:267663] activity 170: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.262796 NSTimerTest[1121:267663] activity 174: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.264645 NSTimerTest[1121:267663] activity 178: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.265702 NSTimerTest[1121:267663] activity 182: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.266818 NSTimerTest[1121:267663] activity 186: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.268355 NSTimerTest[1121:267663] activity 190: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.269167 NSTimerTest[1121:267663] activity 194: kCFRunLoopBeforeWaiting
2017-03-18 13:01:54.269909 NSTimerTest[1121:267663] activity 198: kCFRunLoopBeforeWaiting
NSTimer
2017-03-18 13:01:54.127460 NSTimerTest[1121:267663] timer do nothing, timerCount = 0
2017-03-18 13:01:54.135893 NSTimerTest[1121:267663] timer do nothing, timerCount = 1
2017-03-18 13:01:54.140639 NSTimerTest[1121:267663] timer do nothing, timerCount = 2
2017-03-18 13:01:54.142266 NSTimerTest[1121:267663] timer do nothing, timerCount = 3
2017-03-18 13:01:54.143658 NSTimerTest[1121:267663] timer do nothing, timerCount = 4
2017-03-18 13:01:54.147695 NSTimerTest[1121:267663] timer do nothing, timerCount = 5
2017-03-18 13:01:54.151489 NSTimerTest[1121:267663] timer do nothing, timerCount = 6
2017-03-18 13:01:54.154552 NSTimerTest[1121:267663] timer do nothing, timerCount = 7
2017-03-18 13:01:54.156480 NSTimerTest[1121:267663] timer do nothing, timerCount = 8
2017-03-18 13:01:54.159303 NSTimerTest[1121:267663] timer do nothing, timerCount = 9
2017-03-18 13:01:54.161246 NSTimerTest[1121:267663] timer do nothing, timerCount = 10
2017-03-18 13:01:54.163655 NSTimerTest[1121:267663] timer do nothing, timerCount = 11
2017-03-18 13:01:54.170411 NSTimerTest[1121:267663] timer do nothing, timerCount = 12
2017-03-18 13:01:54.226209 NSTimerTest[1121:267663] timer do nothing, timerCount = 13
2017-03-18 13:01:54.228032 NSTimerTest[1121:267663] timer do nothing, timerCount = 14
2017-03-18 13:01:54.231912 NSTimerTest[1121:267663] timer do nothing, timerCount = 15
2017-03-18 13:01:54.234140 NSTimerTest[1121:267663] timer do nothing, timerCount = 16
2017-03-18 13:01:54.235779 NSTimerTest[1121:267663] timer do nothing, timerCount = 17
2017-03-18 13:01:54.236939 NSTimerTest[1121:267663] timer do nothing, timerCount = 18
2017-03-18 13:01:54.238231 NSTimerTest[1121:267663] timer do nothing, timerCount = 19
2017-03-18 13:01:54.239210 NSTimerTest[1121:267663] timer do nothing, timerCount = 20
2017-03-18 13:01:54.240251 NSTimerTest[1121:267663] timer do nothing, timerCount = 21
2017-03-18 13:01:54.241185 NSTimerTest[1121:267663] timer do nothing, timerCount = 22
2017-03-18 13:01:54.242131 NSTimerTest[1121:267663] timer do nothing, timerCount = 23
2017-03-18 13:01:54.243136 NSTimerTest[1121:267663] timer do nothing, timerCount = 24
2017-03-18 13:01:54.244139 NSTimerTest[1121:267663] timer do nothing, timerCount = 25
2017-03-18 13:01:54.245170 NSTimerTest[1121:267663] timer do nothing, timerCount = 26
2017-03-18 13:01:54.246129 NSTimerTest[1121:267663] timer do nothing, timerCount = 27
2017-03-18 13:01:54.248936 NSTimerTest[1121:267663] timer do nothing, timerCount = 28
2017-03-18 13:01:54.250729 NSTimerTest[1121:267663] timer do nothing, timerCount = 29
2017-03-18 13:01:54.252273 NSTimerTest[1121:267663] timer do nothing, timerCount = 30
2017-03-18 13:01:54.253343 NSTimerTest[1121:267663] timer do nothing, timerCount = 31
2017-03-18 13:01:54.255634 NSTimerTest[1121:267663] timer do nothing, timerCount = 32
2017-03-18 13:01:54.256494 NSTimerTest[1121:267663] timer do nothing, timerCount = 33
2017-03-18 13:01:54.257829 NSTimerTest[1121:267663] timer do nothing, timerCount = 34
2017-03-18 13:01:54.259261 NSTimerTest[1121:267663] timer do nothing, timerCount = 35
2017-03-18 13:01:54.260290 NSTimerTest[1121:267663] timer do nothing, timerCount = 36
2017-03-18 13:01:54.262144 NSTimerTest[1121:267663] timer do nothing, timerCount = 37
2017-03-18 13:01:54.263531 NSTimerTest[1121:267663] timer do nothing, timerCount = 38
2017-03-18 13:01:54.266225 NSTimerTest[1121:267663] timer do nothing, timerCount = 39
2017-03-18 13:01:54.267656 NSTimerTest[1121:267663] timer do nothing, timerCount = 40
2017-03-18 13:01:54.268629 NSTimerTest[1121:267663] timer do nothing, timerCount = 41
2017-03-18 13:01:54.269641 NSTimerTest[1121:267663] timer do nothing, timerCount = 42
2017-03-18 13:01:54.271133 NSTimerTest[1121:267663] timer do nothing, timerCount = 43
2017-03-18 13:01:54.272366 NSTimerTest[1121:267663] timer do nothing, timerCount = 44
2017-03-18 13:01:54.273213 NSTimerTest[1121:267663] timer do nothing, timerCount = 45
2017-03-18 13:01:54.274115 NSTimerTest[1121:267663] timer do nothing, timerCount = 46
2017-03-18 13:01:54.275425 NSTimerTest[1121:267663] timer do nothing, timerCount = 47
2017-03-18 13:01:54.276400 NSTimerTest[1121:267663] timer do nothing, timerCount = 48
2017-03-18 13:01:54.278951 NSTimerTest[1121:267663] timer do nothing, timerCount = 49
2017-03-18 13:01:54.281740 NSTimerTest[1121:267663] timer do nothing, timerCount = 50
2017-03-18 13:01:54.283120 NSTimerTest[1121:267663] timer do nothing, timerCount = 51
2017-03-18 13:01:54.284362 NSTimerTest[1121:267663] timer do nothing, timerCount = 52
CADisplayLink
2017-03-18 13:01:54.138378 NSTimerTest[1121:267663] link do nothing, linkCount = 0
2017-03-18 13:01:54.149657 NSTimerTest[1121:267663] link do nothing, linkCount = 1
2017-03-18 13:01:54.166121 NSTimerTest[1121:267663] link do nothing, linkCount = 2
2017-03-18 13:01:54.225401 NSTimerTest[1121:267663] link do nothing, linkCount = 3
2017-03-18 13:01:54.233023 NSTimerTest[1121:267663] link do nothing, linkCount = 4
2017-03-18 13:01:54.247794 NSTimerTest[1121:267663] link do nothing, linkCount = 5
2017-03-18 13:01:54.265119 NSTimerTest[1121:267663] link do nothing, linkCount = 6
2017-03-18 13:01:54.280689 NSTimerTest[1121:267663] link do nothing, linkCount = 7
2017-03-18 13:01:54.298406 NSTimerTest[1121:267663] link do nothing, linkCount = 8
2017-03-18 13:01:54.315036 NSTimerTest[1121:267663] link do nothing, linkCount = 9
2017-03-18 13:01:54.331416 NSTimerTest[1121:267663] link do nothing, linkCount = 10
2017-03-18 13:01:54.346888 NSTimerTest[1121:267663] link do nothing, linkCount = 11
2017-03-18 13:01:54.363696 NSTimerTest[1121:267663] link do nothing, linkCount = 12
2017-03-18 13:01:54.380435 NSTimerTest[1121:267663] link do nothing, linkCount = 13
2017-03-18 13:01:54.398125 NSTimerTest[1121:267663] link do nothing, linkCount = 14
2017-03-18 13:01:54.414091 NSTimerTest[1121:267663] link do nothing, linkCount = 15
2017-03-18 13:01:54.430187 NSTimerTest[1121:267663] link do nothing, linkCount = 16
2017-03-18 13:01:54.447019 NSTimerTest[1121:267663] link do nothing, linkCount = 17
2017-03-18 13:01:54.463854 NSTimerTest[1121:267663] link do nothing, linkCount = 18
2017-03-18 13:01:54.480343 NSTimerTest[1121:267663] link do nothing, linkCount = 19
2017-03-18 13:01:54.513566 NSTimerTest[1121:267663] link do nothing, linkCount = 21
2017-03-18 13:01:54.530110 NSTimerTest[1121:267663] link do nothing, linkCount = 22
2017-03-18 13:01:54.547502 NSTimerTest[1121:267663] link do nothing, linkCount = 23
2017-03-18 13:01:54.565346 NSTimerTest[1121:267663] link do nothing, linkCount = 24
2017-03-18 13:01:54.580107 NSTimerTest[1121:267663] link do nothing, linkCount = 25
2017-03-18 13:01:54.598014 NSTimerTest[1121:267663] link do nothing, linkCount = 26
2017-03-18 13:01:54.629988 NSTimerTest[1121:267663] link do nothing, linkCount = 28
2017-03-18 13:01:54.646657 NSTimerTest[1121:267663] link do nothing, linkCount = 29
2017-03-18 13:01:54.663800 NSTimerTest[1121:267663] link do nothing, linkCount = 30
2017-03-18 13:01:54.680001 NSTimerTest[1121:267663] link do nothing, linkCount = 31
2017-03-18 13:01:54.697108 NSTimerTest[1121:267663] link do nothing, linkCount = 32
2017-03-18 13:01:54.713726 NSTimerTest[1121:267663] link do nothing, linkCount = 33
2017-03-18 13:01:54.729956 NSTimerTest[1121:267663] link do nothing, linkCount = 34
2017-03-18 13:01:54.746658 NSTimerTest[1121:267663] link do nothing, linkCount = 35
2017-03-18 13:01:54.763778 NSTimerTest[1121:267663] link do nothing, linkCount = 36
2017-03-18 13:01:54.779953 NSTimerTest[1121:267663] link do nothing, linkCount = 37
2017-03-18 13:01:54.796732 NSTimerTest[1121:267663] link do nothing, linkCount = 38
2017-03-18 13:01:54.813729 NSTimerTest[1121:267663] link do nothing, linkCount = 39
2017-03-18 13:01:54.829980 NSTimerTest[1121:267663] link do nothing, linkCount = 40
2017-03-18 13:01:54.846751 NSTimerTest[1121:267663] link do nothing, linkCount = 41
2017-03-18 13:01:54.863757 NSTimerTest[1121:267663] link do nothing, linkCount = 42
2017-03-18 13:01:54.879957 NSTimerTest[1121:267663] link do nothing, linkCount = 43
2017-03-18 13:01:54.896619 NSTimerTest[1121:267663] link do nothing, linkCount = 44
2017-03-18 13:01:54.913648 NSTimerTest[1121:267663] link do nothing, linkCount = 45
2017-03-18 13:01:54.930006 NSTimerTest[1121:267663] link do nothing, linkCount = 46
2017-03-18 13:01:54.946953 NSTimerTest[1121:267663] link do nothing, linkCount = 47
2017-03-18 13:01:54.963751 NSTimerTest[1121:267663] link do nothing, linkCount = 48
2017-03-18 13:01:54.980065 NSTimerTest[1121:267663] link do nothing, linkCount = 49
3、总结
可以看出来,CADisplayLink“尽量”保证17ms执行一次,主要看NSRunloop中有没有执行其它事件时被阻塞
NSTimer的触发周期最小可以和NSRunloop的循环保持一致,也就是由NSRunloop的执行周期决定,大概2~3ms
因此这也是NSTimer也是不精确的原因
代码:https://github.com/liqiushui/NSRunloop
NSTimer的精确度的更多相关文章
- CADisplayLink以及和NSTimer的区别
什么是CADisplayLink CADisplayLink是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器.我们在应用中创建一个新的 CADisplayLink 对象,把它添加到一个r ...
- iOS - OC NSTimer 定时器
前言 @interface NSTimer : NSObject 作用 在指定的时间执行指定的任务. 每隔一段时间执行指定的任务. 1.定时器的创建 当定时器创建完(不用 scheduled 的,添加 ...
- iOS开发中深入理解CADisplayLink和NSTimer
一.什么是CADisplayLink 简单地说,它就是一个定时器,每隔几毫秒刷新一次屏幕. CADisplayLink是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器.我们在应用中创建一 ...
- iOS开发--计时器-NSTimer与CADisplayLink
如果程序要让某个方法重复执行,可以借助定时器来完成.CADisplayLink是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器,NSTimer的精确度低了点,比如NSTimer的触发时间 ...
- 深入理解CADisplayLink和NSTimer
一.什么是CADisplayLink 简单地说,它就是一个定时器,每隔几毫秒刷新一次屏幕. CADisplayLink是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器.我们在应用中创建一 ...
- iOS---->CADisplayLink、比NSTimer更精确的定时器
什么是CADisplayLink CADisplayLink是一个能让我们以和屏幕刷新率相同的频率将内容画到屏幕上的定时器.我们在应用中创建一个新的 CADisplayLink 对象,把它添加到一个r ...
- CADisplayLink & NSTimer
屏幕刷新与UI更新不同步:屏幕刷新由硬件(+GPU)保证,UI更新由软件(CPU保证). 出现卡顿的原因是软件的计算速度跟不上硬件的刷新速度. 一 简介 1 所在框架 CADisplayLink和其它 ...
- iOS中定时器的使用
1. NSTimer 不是很精确 2.CADisplayLink 屏幕 3.通过GCD来实现定时间器 //定时循环执行事件 //dispatch_source_set_timer 方法值得一提的是最后 ...
- Core Animation系列之CADisplayLink
一直以来都想好好学习下CoreAnimation,奈何涉及的东西太多,想要一次性全部搞定时间上不允许,以后会断断续续的补全.最近项目里用到了CADisplayLink,就顺便花点时间看了看. 一.简介 ...
随机推荐
- asp.net客户端IP跟踪
/// <summary> /// 获取客户端IP地址(无视代理) /// </summary> /// <returns>若失败则返回回送地址</retur ...
- 如何在项目中引入MetaQ消息收发机制
当需要异步发送和接收大量消息时,需要在Crystal项目中引入MetaQ消息收发机制. 关于MetaQ使用的官方例子可参考:https://github.com/killme2008/Metamorp ...
- 修改/home内子目录的名字
每次装Linux系统我都会直接安装英文版,虽然中文版方便使用,但是在终端里面会有诸多不便,例如/home目录里面那些子文件夹就是一个很大的麻烦了,不过如果你安装了中文版的系统,还是有办法改成英文的. ...
- 实现jul 日志重定向到 slf4j
需求背景 jul 指的是java.util.logging,是 java 内置的日志模块,目前流行的Java日志组件还包括 jcl(common-logging).slf4j/log4j/logbac ...
- Activity启动过程分析
Android的四大组件中除了BroadCastReceiver以外,其他三种组件都必须在AndroidManifest中注册,对于BroadCastReceiver来说,它既可以在AndroidMa ...
- SQL SERVER运维日记--收缩数据库
一个小故事 某天,小王正在和HR妹妹闲聊,正HAPPY时,,突然收到系统告警消息,数据库磁盘被剩余空间500M,OMG,不行,磁盘快满了,要是业务要停了,,那就小王只能删库到跑路了,,, 先检查下,有 ...
- 转:微信开发之使用java获取签名signature(贴源码,附工程)
微信开发之使用java获取签名signature(贴源码,附工程) 标签: 微信signature获取签名 2015-12-29 22:15 6954人阅读 评论(3) 收藏 举报 分类: 微信开发 ...
- Angular企业级开发(7)-MVC之控制器
1.MVC中的控制器 AngularJS的控制器主要为了把模型和视图连接在一起.大多数业务逻辑操作都会放在视图对应的控制器中.当然如果我们能够把业务逻辑放到后端的REST服务中,就可以开发轻量级Ang ...
- 【Zookeeper】源码分析之请求处理链(二)
一.前言 前面学习了请求处理链的RequestProcessor父类,接着学习PrepRequestProcessor,其通常是请求处理链的第一个处理器. 二.ZooKeeper源码分析 2.1 类的 ...
- cloudbase-init 自动扩盘的副作用 - 每天5分钟玩转 OpenStack(154)
这是 OpenStack 实施经验分享系列的第 4 篇. cloudbase-init 的一项功能是自动扩展 windows 的 C 盘.比如 windows 镜像是 20G,在部署 instance ...