Skip to content

Commit 9b0266c

Browse files
committed
[Concurrency] Stub out an experimental concurrency support library.
The experimental concurrency model will require a supporting runtime and possibly end-user-visible library constructs. Introduce a stub of such a library, enabled by a new `build-script` option `--enable-experimental-concurrency`, so we have a place to put this work.
1 parent 28884ff commit 9b0266c

File tree

14 files changed

+148
-3
lines changed

14 files changed

+148
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,10 @@ option(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING
402402
"Enable experimental Swift differentiable programming features"
403403
FALSE)
404404

405+
option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
406+
"Enable experimental Swift concurrency model"
407+
FALSE)
408+
405409
#
406410
# End of user-configurable options.
407411
#
@@ -852,6 +856,7 @@ if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_SDK_OVERLAY)
852856
message(STATUS "")
853857

854858
message(STATUS "Differentiable Programming Support: ${SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING}")
859+
message(STATUS "Concurrency Support: ${SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY}")
855860
message(STATUS "")
856861
else()
857862
message(STATUS "Not building Swift standard library, SDK overlays, and runtime")

stdlib/public/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ if(SWIFT_BUILD_STDLIB)
8989
if(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
9090
add_subdirectory(Differentiation)
9191
endif()
92+
93+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
94+
add_subdirectory(Concurrency)
95+
endif()
9296
endif()
9397

9498
if(SWIFT_BUILD_STDLIB OR SWIFT_BUILD_REMOTE_MIRROR)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#===--- CMakeLists.txt - Concurrency support library ---------------------===#
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2019 - 2020 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
#
11+
#===----------------------------------------------------------------------===#
12+
13+
add_swift_target_library(swift_Concurrency ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} IS_STDLIB
14+
PartialAsyncTask.swift
15+
16+
SWIFT_MODULE_DEPENDS_OSX Darwin
17+
SWIFT_MODULE_DEPENDS_IOS Darwin
18+
SWIFT_MODULE_DEPENDS_TVOS Darwin
19+
SWIFT_MODULE_DEPENDS_WATCHOS Darwin
20+
SWIFT_MODULE_DEPENDS_LINUX Glibc
21+
SWIFT_MODULE_DEPENDS_FREEBSD Glibc
22+
SWIFT_MODULE_DEPENDS_OPENBSD Glibc
23+
SWIFT_MODULE_DEPENDS_CYGWIN Glibc
24+
SWIFT_MODULE_DEPENDS_HAIKU Glibc
25+
SWIFT_MODULE_DEPENDS_WINDOWS MSVCRT
26+
27+
SWIFT_COMPILE_FLAGS
28+
${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS}
29+
-parse-stdlib
30+
LINK_FLAGS "${SWIFT_RUNTIME_SWIFT_LINK_FLAGS}"
31+
DARWIN_INSTALL_NAME_DIR "@rpath"
32+
INSTALL_IN_COMPONENT stdlib)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Swift
14+
@_implementationOnly import _SwiftConcurrencyShims
15+
16+
public struct PartialAsyncTask {
17+
private var context: UnsafeMutablePointer<_SwiftContext>
18+
19+
public func run() { }
20+
}

stdlib/public/SwiftShims/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(sources
2020
ThreadLocalStorage.h
2121
UnicodeShims.h
2222
Visibility.h
23+
_SwiftConcurrency.h
2324

2425
CoreMediaOverlayShims.h
2526
DispatchOverlayShims.h
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===--- _SwiftConcurrency.h - Swift Concurrency Support --------*- C++ -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
//
13+
// Defines types and support functions for the Swift concurrency model.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
#ifndef SWIFT_CONCURRENCY_H
17+
#define SWIFT_CONCURRENCY_H
18+
19+
#ifdef __cplusplus
20+
namespace swift {
21+
extern "C" {
22+
#endif
23+
24+
typedef struct _SwiftContext {
25+
struct _SwiftContext *parentContext;
26+
} _SwiftContext;
27+
28+
#ifdef __cplusplus
29+
} // extern "C"
30+
} // namespace swift
31+
#endif
32+
33+
#endif // SWIFT_CONCURRENCY_H

stdlib/public/SwiftShims/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ module _SwiftClockKitOverlayShims {
8080
module _SwiftCoreMediaOverlayShims {
8181
header "CoreMediaOverlayShims.h"
8282
}
83+
84+
module _SwiftConcurrencyShims {
85+
header "_SwiftConcurrency.h"
86+
}

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ normalize_boolean_spelling(SWIFT_ASAN_BUILD)
163163
normalize_boolean_spelling(SWIFT_BUILD_SYNTAXPARSERLIB)
164164
normalize_boolean_spelling(SWIFT_ENABLE_SOURCEKIT_TESTS)
165165
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING)
166+
normalize_boolean_spelling(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
166167
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED)
167168

168169
set(profdata_merge_worker
@@ -363,6 +364,10 @@ _Block_release(void) { }\n")
363364
list(APPEND LIT_ARGS "--param" "differentiable_programming")
364365
endif()
365366

367+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY)
368+
list(APPEND LIT_ARGS "--param" "concurrency")
369+
endif()
370+
366371
foreach(test_subset ${TEST_SUBSETS})
367372
set(directories)
368373
set(dependencies ${test_dependencies})

test/lit.site.cfg.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ if '@SWIFT_INCLUDE_TOOLS@' == 'TRUE':
125125

126126
if "@SWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING@" == "TRUE":
127127
config.available_features.add('differentiable_programming')
128+
if "@SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY@" == "TRUE":
129+
config.available_features.add('concurrency')
128130

129131
# Let the main config do the real work.
130132
if config.test_exec_root is None:

test/stdlib/Concurrency.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-typecheck-verify-swift
2+
// REQUIRES: concurrency
3+
4+
// Make sure the import succeeds
5+
import _Concurrency
6+
7+
// Make sure the type shows up
8+
extension PartialAsyncTask {
9+
}

0 commit comments

Comments
 (0)