Commit Graph

24 Commits

Author SHA1 Message Date
Alastair Houghton
da42d728d7 [Concurrency][Windows] Remove unnecessary includes.
TaskLocal.cpp doesn't need <handleapi.h> or <processthreadsapi.h>, both of
which want <windows.h>, which isn't included any more.

rdar://90776105
2022-05-24 14:57:41 +01:00
Alastair Houghton
63a09007a1 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-05-24 14:57:39 +01:00
Saleem Abdulrasool
a8b0ee24dc runtime: blanket application of namespacing and inclusion of new
Apply a blanket pass of including `new` for the placement new allocation
and namespacing the call to the global placement new allocator.  This
should repair the Android ARMv7 builds.
2022-04-14 14:21:12 -07:00
Kuba (Brecka) Mracek
ffb1cacac3 [Concurrency] Avoid using asl_log when not available (#41277) 2022-02-09 09:40:53 -08:00
Mike Ash
2d6a6927e9 Merge pull request #38162 from mikeash/concurrency-constant-pthread-keys
[Concurrency] Use pthread_specific for thread-local storage on Darwin.
2021-07-02 13:22:15 -04:00
Konrad `ktoso` Malawski
bb16d734f3 [Concurrency] add TaskLocal::Item:iisParentPointer for cleaner API 2021-07-02 11:53:50 +09:00
Konrad `ktoso` Malawski
cd0708b315 [Concurrency] task local must not copy null values 2021-07-02 11:36:20 +09:00
Mike Ash
190d3fd22e [Concurrency] Use pthread_specific for thread-local storage on Darwin.
The pthread_specific APIs are better than C++ thread_local storage on Darwin since we can use Swift's reserved pthread keys there.

rdar://79504652
2021-06-29 16:56:59 -04:00
Konrad `ktoso` Malawski
0cf6d9a18a [TaskLocal] copyTo must initializeWithCopy the task local value (#37988) 2021-06-23 15:45:37 +09:00
John McCall
db3967f41d Future-proof the layout of AsyncTask. 2021-05-20 15:30:48 -04:00
Konrad `ktoso` Malawski
6cbb792f92 [TaskLocals] Propagate task-locals through async{} 2021-05-11 11:06:17 +09:00
Konrad `ktoso` Malawski
82e91b7785 [TaskLocals] Enable sync functions to bind task-locals; Keep Storage in TLS 2021-05-11 11:06:16 +09:00
Konrad `ktoso` Malawski
5ff76c6a0d [TaskLocals] Windows: fix missing io.h
TaskLocals print a verbose error before crashing if API is abused within a task-group.
This printing needs `io.h` on windows.
2021-04-30 17:00:24 +09:00
Konrad `ktoso` Malawski
6f3dac190a [TaskLocals] remove TaskLocalInheritance, we'll introduce when needed 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
664936cd03 [TaskLocal] crash on illegal withValue 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
58ea749304 [TaskLocal] Crash on inapropriate use within task group 2021-04-29 15:48:22 +09:00
Konrad `ktoso` Malawski
3d96d05546 [TaskLocals] property wrapper keys 2021-04-29 15:48:09 +09:00
Mike Ash
6aab257c33 [Concurrency] Add compatibility overrides to Concurrency library.
Take the existing CompatibilityOverride mechanism and generalize it so it can be used in both the runtime and Concurrency libraries. The mechanism is preprocessor-heavy, so this requires some tricks. Use the SWIFT_TARGET_LIBRARY_NAME define to distinguish the libraries, and use a different .def file and mach-o section name accordingly.

We want the global/main executor functions to be a little more flexible. Instead of using the override mechanism, we expose function pointers that can be set by the compatibility library, or by any other code that wants to use a custom implementation.

rdar://73726764
2021-03-22 11:09:06 -04:00
John McCall
6c879d6fd3 Change the async ABI to not pass the active task and executor.
Most of the async runtime functions have been changed to not
expect the task and executor to be passed in.  When knowing the
task and executor is necessary, there are runtime functions
available to recover them.

The biggest change I had to make to a runtime function signature
was to swift_task_switch, which has been altered to expect to be
passed the context and resumption function instead of requiring
the caller to park the task.  This has the pleasant consequence
of allowing the implementation to very quickly turn around when
it recognizes that the current executor is satisfactory.  It does
mean that on arm64e we have to sign the continuation function
pointer as an argument and then potentially resign it when
assigning into the task's resume slot.

rdar://70546948
2021-03-16 22:52:54 -04:00
Konrad `ktoso` Malawski
fcb1c01a36 [TaskLocal] Use the task-local stack discipline allocator 2021-03-02 11:14:41 +09:00
Konrad `ktoso` Malawski
d7169edc21 [TaskLocals] Cleanly separate locals impl from Task, no need for fragment 2021-03-02 00:54:47 +09:00
Konrad `ktoso` Malawski
d2bd6abe61 [Concurrency] TaskLocals allow configuring inheritance: never 2021-02-13 20:09:11 +09:00
Konrad `ktoso` Malawski
b811b12246 [Concurrency] TaskLocals lookup "skip" optimization 2021-02-13 10:39:22 +09:00
Konrad `ktoso` Malawski
1044723787 [Concurrency] Initial Task Local Values implementation 2021-02-13 10:39:22 +09:00