草庐IT

event-dispatch-thread

全部标签

使用RT-Thread Studio搭配STM32CubeMX新建RT-Thread项目

STM32CubeMX下载RT-ThreadStudio下载安装好RT-ThreadStudio后,先打开RT-ThreadSDK管理器确认有没有自己MCU需要的SDK包,直接安装好之后里面是有STM32F1系列的SDK包,其他的需要自己安装。之后点击文件→新建→RT-Thread项目,根据自己需要配置好后点击完成就会生成RT-Thread项目。新建项目后点击构建,这时候应该是不会报错的,直接下载进板子里就会打印出RT-Thread的信息。如果没有打印出信息,这个时候调试可能会发现进入rt_hw_hard_fault_exception()函数的while(1)循环中。如果出现这种错误,可以试

ios - Swift Realm Write方法是Sync或Async Thread

我在我的项目中使用Realm,我想知道realm.write()方法是否是同步的。我的例子在这里:letrealm=try!Realm()try!realm.write{realm.delete(message)}realm.invalidate()在上面的例子中,我正在删除一个Realm对象和我写的外括号invalidate()这是我的困惑:如果write()是同步的,那么invalidate()就可以了如果Async比之前writeinvalidate会调用,realm会释放但操作在后台运行谢谢 最佳答案 Realm.write

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

ios - DispatchQueue 在 Swift 中与 main.sync 崩溃

请向我解释为什么会发生此崩溃?Thread1:EXC_BAD_INSTRUCTION(code=EXC_I386_INVOP,subcode=0x0)在这DispatchQueue.main.sync{print("sync")}这是我的代码。overridefuncviewDidLoad(){super.viewDidLoad()print("Start")DispatchQueue.main.async{print("async")}DispatchQueue.main.sync{print("sync")}print("Finish")} 最佳答案

ios - swift 2 : struct thread-safety

在我的快速实践中,我编写了名为OrderedSet的简单结构。我尝试将OrderedSet作为GCD串行队列的线程安全。但它不起作用。测试结果不稳定。我期望是这样的:20:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19]但收到了类似的东西2:[3,19]这里是playground代码:importFoundationimportXCPlaygroundstructOrderedSet{mutatingfuncappend(e:T){dispatch_sync(q){if!self.__elements.contains(e){sel

C# 多线程一: Thread 的简单理解与运用

目录一:进程和线程的关系二:线程的组成三:多线程的实现四:C#中的线程(Thread)1.命名空间2.构造函数3.属性(1).常用属性        Name:        Priority:       IsAlive:        IsBackground:        ThreadState:(2).其他属性4.方法(1).常用方法:        publicvoidStart()        publicstaticvoidSleep(intmillisecondsTimeout)        publicvoidAbort()        publicstaticvoi

ios - swift 中的 dispatch_block_t 相当于什么?

我有一些我想理解的objective-c代码,以便在swift中执行相同的操作:dispatch_block_tadjustTooltipVisibility=^{self.tooltipView.alpha=_tooltipVisible?1.0:0.0;self.tooltipTipView.alpha=_tooltipVisible?1.0:0.0;};到目前为止,关于dispatch_block_t我能找到的所有信息是它在swift的dispatch_after中用作闭包。所以我能理解,但我不明白它在objective-c中的用法,以及如何将这段代码转换为swift代码

ios - 具有父类(super class)和子类的 Swift 协议(protocol)扩展方法分派(dispatch)

我发现了一个有趣的行为,它看起来像是一个错误......基于以下文章描述的行为:https://medium.com/ios-os-x-development/swift-protocol-extension-method-dispatch-6a6bf270ba94http://nomothetis.svbtle.com/the-ghost-of-swift-bugs-future当我添加SomeSuperclass而不是直接采用协议(protocol)时,输出不是我所期望的。protocolTheProtocol{funcmethod1()}extensionTheProtocol{