- Catalina
- Big Sur
- Monterey
- Ventura
- Sonoma
import "dart:async"; | |
/// A cancelable zone. | |
/// | |
/// A [Zone], and a [cancel] function which makes the zone stop processing events. | |
/// After calling [cancel], the zone's timers, microtasks and `run` methods | |
/// ([Zone.run], [Zone.runUnary] and [Zone.runBinary]) stop doing anything. | |
/// Calling the `run` methods will throw, and any scheduled timers or | |
/// microtasks will do nothing instead of calling the configured callback. | |
class CancelableZone { |
// MIT License | |
// | |
// Copyright (c) 2020 Simon Lightfoot | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: |
import 'package:logger/logger.dart'; | |
void main() async { | |
/// Setup logging service | |
final remoteUrl = Uri.parse('http://localhost:8080'); | |
final logger = LoggingService( | |
loggers: { | |
ConsoleLogger(), | |
RemoteLogger(baseUrl: remoteUrl), | |
}, |
import Foundation | |
func reverseDNS(ip: String) -> String { | |
var results: UnsafeMutablePointer<addrinfo>? = nil | |
defer { | |
if let results = results { | |
freeaddrinfo(results) |
See how a minor change to your commit message style can make a difference.
Tip
Take a look at git-conventional-commits , a CLI util to ensure these conventions, determine version and generate changelogs
// By PixelToast | |
var src = | |
"mov r0, #69\n" | |
"bx lr\n" | |
"ldmedeq ip!, {a3-sp}\n" | |
"strbhi r13, [v2, lr, asr #3]!\n" | |
"ldrls a3, [sb], sp, asr #0x14\n"; | |
main() { |
The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).
My take-aways are:
-
You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.
-
Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse
// listening for current item change | |
self.audioQueueObserver = self.playerQueue?.observe(\.currentItem, options: [.new]) { | |
[weak self] (player, _) in | |
print("media item changed...") | |
} | |
// listening for current item status change | |
self.audioQueueStatusObserver = self.playerQueue?.currentItem?.observe(\.status, options: [.new, .old], changeHandler: { | |
(playerItem, change) in | |
if playerItem.status == .readyToPlay { |