草庐IT

DISPATCH_TIME_NOW

全部标签

swift - 如何在 Swift 中为 `dispatch_function_t` 声明 `dispatch_async_f`?

Xcode7beta5。我正在尝试使用dispatch_async_f来避免阻塞。funcmyFirstFunc(){letidentifier=QOS_CLASS_BACKGROUNDletqueue=dispatch_get_global_queue(identifier,0)letcontext:UnsafeMutablePointer=nilletwork:dispatch_function_t=myOtherFuncdispatch_async_f(queue,context,work)}funcmyOtherFunc(context:UnsafeMutablePointer

ios - Swift 3 中的 DISPATCH_QUEUE_T

这个问题在这里已经有了答案:HowtocreatedispatchqueueinSwift3(15个答案)关闭6年前。我正在编写我的第一个Swift3,但我遇到了以下错误dispatch_queue_t在swift中不可用。varqueue:dispatch_queue_t?vardebugPrint=falsepublicinit(){letuuid=NSUUID().uuidStringletqueueLabel="tomlogger-queue-"+uuidqueue=dispatch_queue_create(queueLabel,DISPATCH_QUEUE_SERIAL)}

time - 你如何获得 "current system time"?

SKScene-update的文档如下:“当前系统时间”到底是什么?除了通过SKScene-update之外,我该如何获取它?我试过CFAbsoluteTimeGetCurrent(),但显然是这样Returnsthecurrentsystemabsolutetime[,whichis]ismeasuredinsecondsrelativetotheabsolutereferencedateofJan1200100:00:00GMT.并且与“当前系统时间”不同,根据我的测试,“当前系统时间”的值比“当前绝对时间”小几个数量级。 最佳答案

Swift:从 dispatch_async 内部返回结果

所以我这里有一段代码不起作用。这是因为它在尝试解包可选值时发现nil。这是因为它在异步方法中被初始化。我的问题是,如何在函数获取结果之前推迟返回函数?structDomain{varname:String?vartld:String?varcombined:String{get{returnself.name!+self.tld!}}varwhoIs:String{get{ifself.whoIs.isEmpty{varresult:String?dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAU

ios - dispatch_async 是否可以中断调用任务

假设我将任务异步分派(dispatch)到队列:{//weareonmainqueuedispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{print("taskB")});print("taskA")//somelongrunningworkprint("taskA")//somelongrunningworkprint("taskA")...}在任何情况下,分派(dispatch)的任务都可以中断从中分派(dispatch)它的任务吗?换句话说,是否会在打印所有“任务A”之前打印“

论文笔记:PhaseNet: a deep-neural-network-based seismic arrival-time pickingmethod

2018GeophysicalJournalInternational1Intro1.1Motivation地震检测和定位是地震学的基础。地震目录的质量主要取决于到达时间测量的数量和准确性。地震到达时间测量或相位选择通常由网络分析员执行,他们根据专家判断和多年经验选择相位。随着地震仪部署速度的不断加快;网络分析员分析的速度跟上数据流增加的速度得越来越困难。 地震的相位选择尤其受到S波的挑战,因为它们不是最先到达的波,而是从P尾波的散射波中出现的。S波到达时间特别有用它们可用于减少仅基于P波的地震位置的深度-震源权衡 S波结构对于强地面运动预测很重要。 1.2relatedworks很多研究致力

报错 DOTWEEN ► Tween startup failed (NULL target/property - ): the tween will now be killed...的解决办法

问题描述UI面板中使用了DOTween插件实现一个效果,在退出UI时消耗了UI面板,此时产生报错。DOTWEEN►Tweenstartupfailed(NULLtarget/property-):thetweenwillnowbekilled►Theobjectoftype‘RectTransform’hasbeendestroyedbutyouarestilltryingtoaccessit.Yourscriptshouldeithercheckifitisnulloryoushouldnotdestroytheobject.报错如下图错误分析及解决办法结合这段错描述,我在调用DOScale

ios - 使用 performBackgroundTask 将多个核心数据插入分派(dispatch)到 NSPersistentContainer 时合并冲突

我正在试验新的核心数据APINSPersistentContainer,我的印象是内部排队机制会阻止写入事务并发评估,详见堆栈溢出答案NSPersistentContainerconcurrencyforsavingtocoredataThewaythatalotofproshavebeendealingwiththeproblemforalongtime(evenbeforeNSPersistentContainerdidit)wastohaveanoperationqueuetoqueuethewritessothereisonlyonewritegoingonatatime,an

ios - 在 Swift 中,如何从 dispatch_time_t 获取 NSDate?

“Walltime”是GrandCentralDispatch使用的一种鲜为人知的时间格式。苹果在这里谈论它:https://developer.apple.com/library/ios/documentation/Performance/Reference/GCD_libdispatch_Ref/虽然有些事情确实很方便,但它是一个粘性wicket。很难让它与其他时间格式兼容,这就是我的问题所在。我可以通过将NSDate转换为timespec来制作walltime,然后使用dispatch_walltime:letnow=NSDate().timeIntervalSince1970l

swift - swift 3.0 中的 dispatch_group_async 函数

我的问题是如何在Swift3中正确翻译此函数,因为我注意到有很多关于dispatch_async的文档,但没有任何关于dispatch_group_async的文档>dispatch_group_async(group,dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0)){[unownedself]in 最佳答案 试试这个:letgroup=DispatchGroup()DispatchQueue.global(qos:.userInitiated).async(group:g