Files
swift-mirror/stdlib/public/SwiftShims/_SwiftConcurrency.h
Evan Wilde 6b16657922 Explode on uncaught error thrown in main
This patch has two desirable effects for the price of one.
 1. An uncaught error thrown from main will now explode
 2. Move us off of using runAsyncAndBlock

The issue with runAsyncAndBlock is that it blocks the main thread
outright. UI and the main actor need to run on the main thread or bad
things happen, so blocking the main thread results in a bad day for
them.

Instead, we're using CFRunLoopRun to run the core-foundation run loop on
the main thread, or, dispatch_main if CFRunLoopRun isn't available.
The issue with just using dispatch_main is that it doesn't actually
guarantee that it will run the tasks on the main thread either, just
that it clears the main queue. We don't want to require everything that
uses concurrency to have to include CoreFoundation either, but dispatch
is already required, which supplies dispatch_main, which just empties
out the main queue.
2021-01-13 15:49:28 -08:00

38 lines
1010 B
C++

//===--- _SwiftConcurrency.h - Swift Concurrency Support --------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// Defines types and support functions for the Swift concurrency model.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_CONCURRENCY_H
#define SWIFT_CONCURRENCY_H
#ifdef __cplusplus
namespace swift {
extern "C" {
#endif
typedef struct _SwiftContext {
struct _SwiftContext *parentContext;
} _SwiftContext;
void exit(int);
#define EXIT_SUCCESS 0
#ifdef __cplusplus
} // extern "C"
} // namespace swift
#endif
#endif // SWIFT_CONCURRENCY_H