{"id":352955,"date":"2024-05-20T22:18:29","date_gmt":"2024-05-20T22:18:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=352955"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=352955","title":{"rendered":"<span>\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 Swift Concurrency<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u041f\u0438\u043c\u0430\u043d\u043e\u0432 \u0438 \u041a\u0430\u043c\u0438\u043b\u044c \u0418\u0448\u043c\u0443\u0440\u0430\u0442\u043e\u0432, \u043c\u044b iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 IBS. \u0412 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 unit-\u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043a\u0430\u043a \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u043e Swift 5.5, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0418 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/717\/dbe\/1db\/717dbe1db10eb76888ab9d7adc93aae4.png\" width=\"1274\" height=\"720\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/717\/dbe\/1db\/717dbe1db10eb76888ab9d7adc93aae4.png\"\/><\/figure>\n<p>\u041d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0441\u043e\u0442\u043d\u0438 \u0443\u043f\u0430\u0432\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 async\/await, \u0445\u043e\u0442\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445. \u041c\u044b \u043d\u0430\u0434\u0435\u044f\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u043d\u0430 WWDC 23 Apple \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0438 \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0435\u0434\u0438\u043d\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"swift\">public final class Isolated&lt;Value>: @unchecked Sendable {     private var _value: Value     private let lock = NSRecursiveLock()          public init(_ value: @autoclosure @Sendable () throws -> Value) rethrows {         self._value = try value()     }          public func withValue&lt;T: Sendable>(_ operation: (inout Value) throws -> T) rethrows -> T {         try self.lock.withLock {             var value = self._value             defer { self._value = value }             return try operation(&amp;value)         }     } } extension Isolated where Value: Sendable {     public var value: Value {         self.lock.withLock {             self._value         }     } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"swift\">func testAsyncBasic() async {         let values = Isolated([String]())                  let task = Task {             values.withValue { $0.append(\"World\") }         }         values.withValue { $0.append(\"Hello\") }         await task.value                  XCTAssertEqual(values.value, [\"Hello\", \"World\"]) }<\/code><\/pre>\n<p>\u041e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.\u00a0<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:32:21.053.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.004) seconds<\/strong><\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, 1000 \u0440\u0430\u0437, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:31:42.126.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 7 failures (0 unexpected) in 4.992 (9.582) seconds<\/strong><\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c task group? \u041c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 task group \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d.<\/p>\n<pre><code class=\"swift\">func testTaskGroup() async {         let values = await withTaskGroup(of: [String].self) { group in             group.addTask { [\"Hello\"] }             group.addTask { [\"World\"] }                          return await group.reduce(into: [], +=)         }                  XCTAssertEqual(values, [\"Hello\", \"World\"]) }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0432 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:33:16.817.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.006 (0.007) seconds<\/strong><\/p>\n<p>\u041f\u0440\u0438 1000 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u0436\u0435 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:34:22.915.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 66 failures (0 unexpected) in 1.799 (2.477) seconds<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/842\/c14\/196\/842c141964c499a3ff7a9218fb4f7671.jpeg\" width=\"1024\" height=\"683\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/842\/c14\/196\/842c141964c499a3ff7a9218fb4f7671.jpeg\" data-blurred=\"true\"\/><\/figure>\n<p>\u0412\u0441\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a.  <\/p>\n<pre><code class=\"swift\">func testTaskGroupOrder() async {       let values = await withTaskGroup(of: [Int].self) { group in         for n in 1...100 {           group.addTask { [n] }         }         return await group.reduce(into: [], +=)       }       XCTAssertEqual(values, Array(1...100))  }<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 1000 \u0440\u0430\u0437.<\/p>\n<p>\u041e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:38:14.266.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.004) seconds<\/strong><\/p>\n<p>\u0421 1000 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0434\u0440\u0443\u0447\u0430\u044e\u0449\u0438\u0439:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:39:51.351.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 921 failures (0 unexpected) in 31.802 (46.776) seconds<\/strong><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/97f\/b0b\/14c\/97fb0b14c2a5aca6d5f6de2785b4124c.jpeg\" width=\"740\" height=\"518\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/97f\/b0b\/14c\/97fb0b14c2a5aca6d5f6de2785b4124c.jpeg\" data-blurred=\"true\"\/><\/figure>\n<h3>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c\u0438<\/h3>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447, \u0431\u0443\u0434\u044c \u0442\u043e unstructured task \u0438\u043b\u0438 task group. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 async let. \u0418 \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0447\u0435\u0442\u043a\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<\/p>\n<p>\u0418 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 Swift Concurrency \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043f\u0443\u043b\u0435 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0430\u043c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0430 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0437\u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u0440\u0430\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043f\u0443\u043b\u0435, \u0438 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438 \u0434\u0430\u0436\u0435 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043f\u0440\u0438\u0441\u0443\u0449 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441: \u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f? \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043a\u0430\u043a? \u0418\u0442\u0430\u043a, \u043e\u0442\u0432\u0435\u0442 \u2014 \u0414\u0410! \u0410 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e, \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043f\u043e \u0441\u0443\u0442\u0438, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u041d\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 executor (\u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043a\u0443\u0442\u043e\u0440.\u00a0<\/p>\n<p>\u0427\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430 Executor, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0432\u0430\u043c \u00ab\u0432\u0442\u0438\u0440\u0430\u0435\u043c\u00bb, \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0422\u0430\u043a \u0432\u043e\u0442 \u0432 Swift \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043f\u0440\u0430\u0432\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432 \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u0434\u0430 \u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apple \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u044b \u043e \u043d\u0435\u043c.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u044d\u0442\u043e\u0442 \u00ab\u0437\u0432\u0435\u0440\u044c\u00bb \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435: <\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public protocol Executor : AnyObject, Sendable {     func enqueue(_ job: UnownedJob) }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043c\u0430\u043b\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u0442\u043e-\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u00ab\u043c\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u00bb \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442 \u043a \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0432 Swift. \u0421\u043a\u0430\u0436\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e-\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443)). \u041a\u0430\u043a \u0442\u043e\u0433\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c Actor, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e MainActor. \u042d\u0442\u043e\u0442 \u0442\u043e\u0432\u0430\u0440\u0438\u0449 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 GlobalActor:<\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public protocol GlobalActor {     associatedtype ActorType : Actor     static var shared: Self.ActorType { get }     static var sharedUnownedExecutor: UnownedSerialExecutor { get } }<\/code><\/pre>\n<p>\u041d\u043e \u0438 \u0437\u0434\u0435\u0441\u044c \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0432\u043e\u0445)). \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0415\u0435 \u0442\u0438\u043f \u2014 UnownedSerialExecutor, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0441\u0432\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 (\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u043e Executor), \u043e\u043d \u0434\u0430\u0436\u0435 \u043d\u0435 \u043a\u043e\u043d\u0444\u043e\u0440\u043c\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b)). \u041c\u0438\u0441\u0442\u0438\u043a\u0430 \u0447\u0438\u0441\u0442\u043e\u0439 \u0432\u043e\u0434\u044b, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438:<\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) @frozen public struct UnownedSerialExecutor : Sendable {     @inlinable public init&lt;E>(ordinary executor: E) where E : SerialExecutor }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, Apple \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e Executor \u0441\u0443\u043f\u0435\u0440\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439. \u041e\u043d\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438, \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430\u043c\u0438.<\/p>\n<p>\u041d\u043e \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0418 \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u044b \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438, \u043e \u043a\u043e\u043c \u0438\u0434\u0451\u0442 \u0440\u0435\u0447\u044c: <strong>MainActor.<\/strong><\/p>\n<p>\u041a\u0440\u0443\u0442\u043e! \u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f? \u0427\u0435\u0440\u0435\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"swift\">MainActor.shared.tunownedExecutor<\/code><\/pre>\n<p>\u041d\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c, \u0438 \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441 \u043d\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"swift\">MainActor.shared.enqueue(job: UnownedJob)<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 executor \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0430\u0441\u043a\u0438, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u043d. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432 MainActor, \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 executor, \u0438 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 executor, \u043d\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u043a\u0440\u044b\u0442\u043e \u043e\u0442 \u043d\u0430\u0441 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432 \u0434\u0435\u0431\u0440\u044f\u0445, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u043d\u0430 \u0421++.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u043c \u0432 \u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0438 \u0442\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u0447\u0435\u0440\u0435\u0434\u0443\u044e\u0442\u0441\u044f. \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u044b \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 Swift.<\/p>\n<h3>\u041f\u0440\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0443\u043a:<\/p>\n<pre><code class=\"swift\">typealias Original = @convention(thin) (UnownedJob) -> Void typealias Hook = @convention(thin) (UnownedJob, Original) -> Void  var swift_task_enqueueGlobal_hook: Hook? {   get { _swift_task_enqueueGlobal_hook.pointee }   set { _swift_task_enqueueGlobal_hook.pointee = newValue } }  private let _swift_task_enqueueGlobal_hook =   dlsym(dlopen(nil, RTLD_LAZY), \"swift_task_enqueueGlobal_hook\")     .assumingMemoryBound(to: Hook?.self)<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442:  <\/p>\n<pre><code class=\"swift\">func testAsyncBasic() async {         swift_task_enqueueGlobal_hook = { job, _ in             MainActor.shared.enqueue(job)         }                  let values = Isolated([String]())                  let task1 = Task {             values.withValue { $0.append(\"Hello\") }         }         let task2 = Task {             values.withValue { $0.append(\"World\") }         }         await (task1.value, task2.value)                  XCTAssertEqual(values.value, [\"Hello\", \"World\"])  }<\/code><\/pre>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-08 11:42:48.305.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 0 failures (0 unexpected) in 0.960<\/strong><\/p>\n<p>\u041c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0438\u0437 1000 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0442\u0435\u0441\u0442\u0430, \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u043e\u0441\u044c 0. \u041a\u0430\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c? \u0410 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u0435: \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0446\u0435\u043b\u044b\u043c \u043f\u0443\u043b\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u044f\u0441\u043d\u0438\u0442\u044c, \u043a\u0430\u043a \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043f\u043e\u0442\u043e\u043a\u0430\u043c. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e, \u0445\u043e\u0442\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0447\u0435\u0442\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0441\u0432\u043e\u0434\u044f \u0432\u0441\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u043c, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u044e \u044d\u0442\u0443 \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c. \u0423 \u0433\u043b\u0430\u0432\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f \u043d\u0435\u0442 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0432\u044b\u0431\u043e\u0440\u0430, \u043a\u0440\u043e\u043c\u0435 \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u043d\u0435 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f, \u0438 \u0432 \u044d\u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u0430 \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e, \u0438 \u0442\u0430\u043a \u0434\u0430\u043b\u0435\u0435. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0442\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447, \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0447\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e)).<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0442\u0435\u0441\u0442\u0443, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u043a \u043d\u0435\u043c\u0443 \u043a\u043e\u0434 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e:<\/p>\n<pre><code class=\"swift\">func testTaskGroupOrder() async {         swift_task_enqueueGlobal_hook = { job, _ in             MainActor.shared.enqueue(job)         }                  let values = await withTaskGroup(of: [Int].self) { group in             for n in 1...100 {                 group.addTask { [n] }             }             return await group.reduce(into: [], +=)         }         XCTAssertEqual(values, Array(1...100)) }<\/code><\/pre>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-08 11:47:43.292.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 0 failures (0 unexpected) in 3.942<\/strong><\/p>\n<p>\u042d\u0442\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u043c\u044b \u0432\u0438\u0434\u0435\u043b\u0438 (\u0431\u0435\u0437 \u0432\u043e\u043b\u0448\u0435\u0431\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u00ab\u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0445\u0443\u043a\u0430\u00bb), \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u043b\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 80% \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u0417\u0430\u043f\u0443\u0441\u043a \u0442\u0430\u043a\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043b \u043a \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u043d\u0438 \u0431\u044b\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u044b. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u0430\u0436\u0435 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0433\u0440\u0443\u043f\u043f \u0437\u0430\u0434\u0430\u0447 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u043c, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u0432\u0435\u0434\u0435\u043c \u0438\u0442\u043e\u0433 \u0432\u0441\u0435\u043c\u0443 \u0442\u043e\u043c\u0443, \u043e \u0447\u0435\u043c \u0448\u043b\u0430 \u0440\u0435\u0447\u044c \u0432\u044b\u0448\u0435. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u043e, \u0432 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u043d\u0430\u0448\u0438 \u0437\u0430\u0434\u0430\u0447\u0438, \u043e\u0434\u043d\u0430\u043a\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043d\u0435\u043b\u044c\u0437\u044f \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u043b\u044e\u0434\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0438\u0445 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u0432\u0430\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u0430\u043c \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u0434\u0430\u0447. \u0422\u0430\u043a \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0437\u044f\u0442\u044c \u043f\u043e\u0434 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0442\u043e, \u043a\u0430\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 Swift. \u041f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u043e\u043d\u0438 \u0441\u0442\u0430\u0432\u044f\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0447\u0435\u0440\u0435\u0434\u0443\u044e\u0442\u0441\u044f \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0438 \u044d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c 100% \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435, \u043f\u0440\u043e\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0442\u0435\u0441\u0442\u044b. \u041c\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0431\u0443\u0434\u0435\u043c \u0436\u0434\u0430\u0442\u044c \u043e\u0442 Apple \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 Executor \u0438 GlobalActor, \u0442\u0430\u043a \u043a\u0430\u043a, \u043f\u043e \u043d\u0430\u0448\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e\u0435 API, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>P. S. \u0410 \u0432\u044b \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439? \u0415\u0441\u043b\u0438 \u0434\u0430, \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0445 \u0432\u0430\u0448\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c) \u041d\u0443 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043b\u044e\u0431\u043e\u0439 \u0444\u0438\u0434\u0431\u0435\u043a \u043f\u043e \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442\u0441\u044f!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/756418\/\"> https:\/\/habr.com\/ru\/articles\/756418\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440! \u041d\u0430 \u0441\u0432\u044f\u0437\u0438 \u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440 \u041f\u0438\u043c\u0430\u043d\u043e\u0432 \u0438 \u041a\u0430\u043c\u0438\u043b\u044c \u0418\u0448\u043c\u0443\u0440\u0430\u0442\u043e\u0432, \u043c\u044b iOS-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 IBS. \u0412 \u043d\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u043c\u044b \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043d\u043e\u0432\u044b\u0435 \u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438 \u0438 \u0441\u0442\u0430\u0440\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0448 \u043a\u043e\u0434 unit-\u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u043a\u0430\u043a \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0440\u0435\u0448\u0438\u0442\u044c.<\/p>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/h3>\n<p>\u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441\u043e Swift 5.5, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 \u0438 \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441. \u0418 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u044b\u043b\u0438 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0435\u0433\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u043e \u0432 \u043f\u043e\u0432\u0441\u0435\u0434\u043d\u0435\u0432\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u044d\u0442\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043d\u0430\u043c \u043e\u0445\u0432\u0430\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u041d\u0430 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u0438 \u0441\u043e\u0442\u043d\u0438 \u0443\u043f\u0430\u0432\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 async\/await, \u0445\u043e\u0442\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u044d\u0442\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0438\u043a\u0430\u043a\u0438\u0445. \u041c\u044b \u043d\u0430\u0434\u0435\u044f\u043b\u0438\u0441\u044c, \u0447\u0442\u043e \u043d\u0430 WWDC 23 Apple \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0438 \u043c\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u043e\u0441\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0435\u0434\u0438\u043d\u0435 \u0441 \u043d\u0430\u0448\u0438\u043c\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438.<\/p>\n<p>\u0414\u043b\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"swift\">public final class Isolated&lt;Value>: @unchecked Sendable {     private var _value: Value     private let lock = NSRecursiveLock()          public init(_ value: @autoclosure @Sendable () throws -> Value) rethrows {         self._value = try value()     }          public func withValue&lt;T: Sendable>(_ operation: (inout Value) throws -> T) rethrows -> T {         try self.lock.withLock {             var value = self._value             defer { self._value = value }             return try operation(&amp;value)         }     } } extension Isolated where Value: Sendable {     public var value: Value {         self.lock.withLock {             self._value         }     } }<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0442\u0430\u043a\u043e\u0433\u043e \u0442\u0435\u0441\u0442\u0430:<\/p>\n<pre><code class=\"swift\">func testAsyncBasic() async {         let values = Isolated([String]())                  let task = Task {             values.withValue { $0.append(\"World\") }         }         values.withValue { $0.append(\"Hello\") }         await task.value                  XCTAssertEqual(values.value, [\"Hello\", \"World\"]) }<\/code><\/pre>\n<p>\u041e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432.\u00a0<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:32:21.053.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.004) seconds<\/strong><\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0433\u043e, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, 1000 \u0440\u0430\u0437, \u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:31:42.126.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 7 failures (0 unexpected) in 4.992 (9.582) seconds<\/strong><\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c task group? \u041c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 task group \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0432 \u0442\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d.<\/p>\n<pre><code class=\"swift\">func testTaskGroup() async {         let values = await withTaskGroup(of: [String].self) { group in             group.addTask { [\"Hello\"] }             group.addTask { [\"World\"] }                          return await group.reduce(into: [], +=)         }                  XCTAssertEqual(values, [\"Hello\", \"World\"]) }<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0435 \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0442\u0435\u0441\u0442\u0430 \u0432 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:33:16.817.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.006 (0.007) seconds<\/strong><\/p>\n<p>\u041f\u0440\u0438 1000 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0443\u0436\u0435 \u0442\u0430\u043a\u0438\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:34:22.915.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 66 failures (0 unexpected) in 1.799 (2.477) seconds<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0441\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u043d\u0435 \u0442\u0430\u043a \u043b\u0438? \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u0434\u0430\u0447 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0438\u0445 \u043f\u043e\u0440\u044f\u0434\u043e\u043a.  <\/p>\n<pre><code class=\"swift\">func testTaskGroupOrder() async {       let values = await withTaskGroup(of: [Int].self) { group in         for n in 1...100 {           group.addTask { [n] }         }         return await group.reduce(into: [], +=)       }       XCTAssertEqual(values, Array(1...100))  }<\/code><\/pre>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u0438 1000 \u0440\u0430\u0437.<\/p>\n<p>\u041e\u0434\u043d\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-03 16:38:14.266.<\/strong><\/p>\n<p><strong>Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.004) seconds<\/strong><\/p>\n<p>\u0421 1000 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0441\u043e\u0432\u0441\u0435\u043c \u0443\u0434\u0440\u0443\u0447\u0430\u044e\u0449\u0438\u0439:<\/p>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; failed at 2023-08-03 16:39:51.351.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 921 failures (0 unexpected) in 31.802 (46.776) seconds<\/strong><\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c\u0441\u044f \u0441 \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c\u0438<\/h3>\n<p>\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u043f\u043e\u0440\u044f\u0434\u043a\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447, \u0431\u0443\u0434\u044c \u0442\u043e unstructured task \u0438\u043b\u0438 task group. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0438 async let. \u0418 \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0447\u0435\u0442\u043a\u043e \u043d\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0439 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0447\u0435\u0440\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0436\u0434\u0443 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0437\u0430\u0434\u0430\u0447\u0430\u043c\u0438.<\/p>\n<p>\u0418 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u043e\u0436\u0438\u0434\u0430\u0442\u044c. \u0412 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 Swift Concurrency \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u043f\u0443\u043b\u0435 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0442\u0430\u043c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u043e\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043b\u0430 \u043a\u0430\u043a\u0443\u044e-\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0443, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0437\u0436\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u043e\u0437\u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435.<\/p>\n<p>\u042d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u0440\u0430\u0432\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043f\u0443\u043b\u0435, \u0438 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0430 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0438 \u0434\u0430\u0436\u0435 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0443\u0434\u0438\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u043c\u0443 \u043a\u043e\u0434\u0443 \u043f\u0440\u0438\u0441\u0443\u0449 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0418 \u0442\u0443\u0442 \u0432\u044b\u0440\u0438\u0441\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441: \u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u0441 \u044d\u0442\u0438\u043c \u0431\u043e\u0440\u043e\u0442\u044c\u0441\u044f? \u0415\u0441\u043b\u0438 \u0434\u0430, \u0442\u043e \u043a\u0430\u043a? \u0418\u0442\u0430\u043a, \u043e\u0442\u0432\u0435\u0442 \u2014 \u0414\u0410! \u0410 \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e, \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0438 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u043c.<\/p>\n<p>\u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0437\u0430\u0434\u0430\u0447 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u0445 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0447\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u043f\u043e \u0441\u0443\u0442\u0438, \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u043e\u0441\u044c, \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439. \u041d\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u044d\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 executor (\u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e), \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u043c\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 \u044d\u043a\u0437\u0435\u043a\u0443\u0442\u043e\u0440.\u00a0<\/p>\n<p>\u0427\u0442\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430 Executor, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043c\u044b \u0432\u0430\u043c \u00ab\u0432\u0442\u0438\u0440\u0430\u0435\u043c\u00bb, \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u0435 \u0432\u044b. \u0422\u0430\u043a \u0432\u043e\u0442 \u0432 Swift \u0435\u0441\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043f\u0440\u0430\u0432\u0434\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u0439 \u0432 \u043a\u043e\u043c\u044c\u044e\u043d\u0438\u0442\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e \u043d\u0435\u0433\u043e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u0437\u043d\u0430\u0435\u0442, \u0434\u0430 \u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 Apple \u043d\u0435 \u043e\u0441\u043e\u0431\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0444\u044b \u043e \u043d\u0435\u043c.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u044d\u0442\u043e\u0442 \u00ab\u0437\u0432\u0435\u0440\u044c\u00bb \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435: <\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public protocol Executor : AnyObject, Sendable {     func enqueue(_ job: UnownedJob) }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u043e\u0431 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0435 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u043c\u0430\u043b\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438, \u043a\u0442\u043e-\u0442\u043e \u0434\u0430\u0436\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0435\u0433\u043e \u00ab\u043c\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u00bb \u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442 \u043a \u0431\u0443\u0434\u0443\u0449\u0435\u043c\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 \u0432 Swift. \u0421\u043a\u0430\u0436\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435, \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e-\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0439 \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443)). \u041a\u0430\u043a \u0442\u043e\u0433\u0434\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c? \u041e\u0442\u0432\u0435\u0442 \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c Actor, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e MainActor. \u042d\u0442\u043e\u0442 \u0442\u043e\u0432\u0430\u0440\u0438\u0449 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u043d\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0430 GlobalActor:<\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public protocol GlobalActor {     associatedtype ActorType : Actor     static var shared: Self.ActorType { get }     static var sharedUnownedExecutor: UnownedSerialExecutor { get } }<\/code><\/pre>\n<p>\u041d\u043e \u0438 \u0437\u0434\u0435\u0441\u044c \u043a\u0440\u043e\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0432\u043e\u0445)). \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0415\u0435 \u0442\u0438\u043f \u2014 UnownedSerialExecutor, \u043e\u0434\u043d\u0430\u043a\u043e, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0441\u0432\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 (\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0441\u043b\u043e\u0432\u043e Executor), \u043e\u043d \u0434\u0430\u0436\u0435 \u043d\u0435 \u043a\u043e\u043d\u0444\u043e\u0440\u043c\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b)). \u041c\u0438\u0441\u0442\u0438\u043a\u0430 \u0447\u0438\u0441\u0442\u043e\u0439 \u0432\u043e\u0434\u044b, \u0443\u0431\u0435\u0434\u0438\u0442\u0435\u0441\u044c \u0441\u0430\u043c\u0438:<\/p>\n<pre><code class=\"swift\">@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) @frozen public struct UnownedSerialExecutor : Sendable {     @inlinable public init&lt;E>(ordinary executor: E) where E : SerialExecutor }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u043c\u044b \u0432\u0438\u0434\u0438\u043c, Apple \u0441\u0442\u0430\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044e Executor \u0441\u0443\u043f\u0435\u0440\u043d\u0435\u043f\u0440\u043e\u0437\u0440\u0430\u0447\u043d\u043e\u0439. \u041e\u043d\u0430 \u043f\u043e\u043a\u0430 \u043d\u0435 \u0445\u043e\u0447\u0435\u0442 \u0440\u0430\u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438, \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0435\u0449\u0435 \u043d\u0435 \u043f\u0440\u043e\u0448\u043b\u0438 \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u0442\u0447\u0430\u0441\u0442\u0438 \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u0438\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043e\u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0432\u043b\u0430\u0434\u0435\u043d\u0438\u0435 \u0442\u0438\u043f\u0430\u043c\u0438.<\/p>\n<p>\u041d\u043e \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u043e\u0431\u0449\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u043b\u0438\u0431\u043e \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u044f\u0441\u044c \u043a \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e. \u0418 \u044d\u0442\u043e\u0442 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u044b \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438 \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u043b\u0438, \u043e \u043a\u043e\u043c \u0438\u0434\u0451\u0442 \u0440\u0435\u0447\u044c: <strong>MainActor.<\/strong><\/p>\n<p>\u041a\u0440\u0443\u0442\u043e! \u041d\u043e \u043a\u0430\u043a \u043d\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043d\u0430\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044f? \u0427\u0435\u0440\u0435\u0437 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u0430\u043a\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"swift\">MainActor.shared.tunownedExecutor<\/code><\/pre>\n<p>\u041d\u043e, \u043a\u0430\u043a \u043c\u044b \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438, \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c, \u0438 \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441 \u043d\u0438\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041e\u0434\u043d\u0430\u043a\u043e, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:  <\/p>\n<pre><code class=\"swift\">MainActor.shared.enqueue(job: UnownedJob)<\/code><\/pre>\n<p>\u042d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 executor \u0432 \u0442\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435, \u0447\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0442\u0430\u0441\u043a\u0438, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u043d. \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432 MainActor, \u0438\u043c\u0438\u0442\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 executor, \u0438 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u043e\u043d \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 executor, \u043d\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0441\u043a\u0440\u044b\u0442\u043e \u043e\u0442 \u043d\u0430\u0441 \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432 \u0434\u0435\u0431\u0440\u044f\u0445, \u0434\u0430 \u0435\u0449\u0435 \u0438 \u043d\u0430 \u0421++.<\/p>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043e\u0447\u0435\u0440\u0435\u0434\u0438, \u0447\u0442\u043e\u0431\u044b \u043e\u043d \u0431\u044b\u043b \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0438\u0441\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u0435\u043c \u0432 \u0442\u0435\u0441\u0442\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438, \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0430\u043c\u044b\u0445 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447 \u0438 \u0442\u043e, \u043a\u0430\u043a \u043e\u043d\u0438 \u0447\u0435\u0440\u0435\u0434\u0443\u044e\u0442\u0441\u044f. \u041a\u043e\u0440\u043e\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u044b \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c\u0430 Swift.<\/p>\n<h3>\u041f\u0440\u0430\u0432\u0438\u043c \u0442\u0435\u0441\u0442\u044b<\/h3>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0443\u043a:<\/p>\n<pre><code class=\"swift\">typealias Original = @convention(thin) (UnownedJob) -> Void typealias Hook = @convention(thin) (UnownedJob, Original) -> Void  var swift_task_enqueueGlobal_hook: Hook? {   get { _swift_task_enqueueGlobal_hook.pointee }   set { _swift_task_enqueueGlobal_hook.pointee = newValue } }  private let _swift_task_enqueueGlobal_hook =   dlsym(dlopen(nil, RTLD_LAZY), \"swift_task_enqueueGlobal_hook\")     .assumingMemoryBound(to: Hook?.self)<\/code><\/pre>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u043d\u043e\u0432\u044b\u0445 \u0432\u0432\u043e\u0434\u043d\u044b\u0445 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442:  <\/p>\n<pre><code class=\"swift\">func testAsyncBasic() async {         swift_task_enqueueGlobal_hook = { job, _ in             MainActor.shared.enqueue(job)         }                  let values = Isolated([String]())                  let task1 = Task {             values.withValue { $0.append(\"Hello\") }         }         let task2 = Task {             values.withValue { $0.append(\"World\") }         }         await (task1.value, task2.value)                  XCTAssertEqual(values.value, [\"Hello\", \"World\"])  }<\/code><\/pre>\n<p><strong>Test Suite &#8216;AsyncTestsTests&#8217; passed at 2023-08-08 11:42:48.305.<\/strong><\/p>\n<p><strong>Executed 1000 tests, with 0 failures<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-352955","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352955","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=352955"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/352955\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=352955"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=352955"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=352955"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}