惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
腾讯CDC
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
罗磊的独立博客
F
Full Disclosure
博客园 - 【当耐特】
C
CERT Recently Published Vulnerability Notes
Engineering at Meta
Engineering at Meta
Application and Cybersecurity Blog
Application and Cybersecurity Blog
T
Threatpost
I
Intezer
V2EX - 技术
V2EX - 技术
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The Hacker News
The Hacker News
小众软件
小众软件
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
B
Blog RSS Feed
Microsoft Security Blog
Microsoft Security Blog
N
News | PayPal Newsroom
MyScale Blog
MyScale Blog
AI
AI
Vercel News
Vercel News
Spread Privacy
Spread Privacy
美团技术团队
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
V
Vulnerabilities – Threatpost
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
Help Net Security
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
L
LINUX DO - 热门话题
U
Unit 42
L
LangChain Blog
Recent Announcements
Recent Announcements

博客园 - bluce chen

oculus quest2的思考 博文阅读密码验证 - 博客园 用户中心 - 博客园 https点对点转发响应示意图 Share架构的一些心得 flutter输入颜色枚举卡顿假死 n2n网络环境搭建 p2p技术之n2n源码核心简单分析一 分享一个14年写的用户管理类-swift版 MIUI通过xposed自动设置root权限 基于xposed实现android注册系统服务,解决跨进程共享数据问题 2017 UICollectionView swift2模版 angularjs 分页精华代码 Reveal分析IOS界面,plist文件读取 php嵌套数组递归搜索返回数组key 结合阿里云服务器,设置家中jetson tk1随时远程登陆 sqlite3 根据实体自动生成建表语句 prism4 StockTrader RI 项目分析一些体会2
swif debounce实现
bluce chen · 2022-01-04 · via 博客园 - bluce chen
//关联`debounceAsyncAfter` 的调用的键。
struct DebounceKey: Equatable, Hashable { fileprivate let lockedState = UnfairLockedState<UInt64>(0) init() {} static func == (lhs: DebounceKey, rhs: DebounceKey) -> Bool { return lhs.lockedState === rhs.lockedState } func hash(into hasher: inout Hasher) { hasher.combine(ObjectIdentifier(lockedState)) } }
//限定时间内只发生一个去抖动的异步块 func debounceAsyncAfter(deadline: DispatchTime, key: DebounceKey, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> Void) { let epoch = key.lockedState.sync { (x) -> UInt64 in x += 1 return x } asyncAfter(deadline: deadline, qos: qos, flags: flags) { guard epoch == key.lockedState.sync({ $0 }) else { return } work() } }
//限定时间内只发生去抖动的一组异步块 func debounceAsyncAfter(wallDeadline: DispatchWallTime, key: DebounceKey, qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], execute work: @escaping () -> Void) { let epoch = key.lockedState.sync { (x) -> UInt64 in x += 1 return x } asyncAfter(wallDeadline: wallDeadline, qos: qos, flags: flags) { guard epoch == key.lockedState.sync({ $0 }) else { return } work() } }