mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
stdlib: remove pthread_attr_t from _stdlib_pthread_create_block
The attributes were not being used currently. Since this is a private interface, remove the parameter as it makes it easier to port to Windows.
This commit is contained in:
@@ -605,24 +605,21 @@ public func runRaceTest<RT : RaceTestWithPerTrialData>(
|
||||
|
||||
// Create the master thread.
|
||||
do {
|
||||
let (ret, tid) = _stdlib_pthread_create_block(
|
||||
nil, masterThreadBody, ())
|
||||
let (ret, tid) = _stdlib_pthread_create_block(masterThreadBody, ())
|
||||
expectEqual(0, ret)
|
||||
testTids.append(tid!)
|
||||
}
|
||||
|
||||
// Create racing threads.
|
||||
for i in 0..<racingThreadCount {
|
||||
let (ret, tid) = _stdlib_pthread_create_block(
|
||||
nil, racingThreadBody, i)
|
||||
let (ret, tid) = _stdlib_pthread_create_block(racingThreadBody, i)
|
||||
expectEqual(0, ret)
|
||||
testTids.append(tid!)
|
||||
}
|
||||
|
||||
// Create the alarm thread that enforces the timeout.
|
||||
do {
|
||||
let (ret, tid) = _stdlib_pthread_create_block(
|
||||
nil, alarmThreadBody, ())
|
||||
let (ret, tid) = _stdlib_pthread_create_block(alarmThreadBody, ())
|
||||
expectEqual(0, ret)
|
||||
alarmTid = tid!
|
||||
}
|
||||
|
||||
@@ -59,15 +59,8 @@ internal func invokeBlockContext(
|
||||
return context.run()
|
||||
}
|
||||
|
||||
#if os(Cygwin) || os(FreeBSD) || os(Haiku)
|
||||
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t?>
|
||||
#else
|
||||
public typealias _stdlib_pthread_attr_t = UnsafePointer<pthread_attr_t>
|
||||
#endif
|
||||
|
||||
/// Block-based wrapper for `pthread_create`.
|
||||
public func _stdlib_pthread_create_block<Argument, Result>(
|
||||
_ attr: _stdlib_pthread_attr_t?,
|
||||
_ start_routine: @escaping (Argument) -> Result,
|
||||
_ arg: Argument
|
||||
) -> (CInt, pthread_t?) {
|
||||
@@ -77,7 +70,7 @@ public func _stdlib_pthread_create_block<Argument, Result>(
|
||||
let contextAsVoidPointer = Unmanaged.passRetained(context).toOpaque()
|
||||
|
||||
var threadID = _make_pthread_t()
|
||||
let result = pthread_create(&threadID, attr,
|
||||
let result = pthread_create(&threadID, nil,
|
||||
{ invokeBlockContext($0) }, contextAsVoidPointer)
|
||||
if result == 0 {
|
||||
return (result, threadID)
|
||||
|
||||
@@ -120,7 +120,7 @@ ExclusiveAccessTestSuite.test("ClosureCaptureReadRead") {
|
||||
// have overlapping accesses
|
||||
ExclusiveAccessTestSuite.test("PerThreadEnforcement") {
|
||||
modifyAndPerform(&globalX) {
|
||||
let (_, otherThread) = _stdlib_pthread_create_block(nil, { (_ : Void) -> () in
|
||||
let (_, otherThread) = _stdlib_pthread_create_block({ (_ : Void) -> () in
|
||||
globalX.i = 12 // no-trap
|
||||
return ()
|
||||
}, ())
|
||||
|
||||
@@ -94,9 +94,9 @@ StringTestSuite.test("SliceConcurrentAppend") {
|
||||
expectEqual(0, ret)
|
||||
|
||||
let (createRet1, tid1) = _stdlib_pthread_create_block(
|
||||
nil, sliceConcurrentAppendThread, .Primary)
|
||||
sliceConcurrentAppendThread, .Primary)
|
||||
let (createRet2, tid2) = _stdlib_pthread_create_block(
|
||||
nil, sliceConcurrentAppendThread, .Secondary)
|
||||
sliceConcurrentAppendThread, .Secondary)
|
||||
|
||||
expectEqual(0, createRet1)
|
||||
expectEqual(0, createRet2)
|
||||
|
||||
Reference in New Issue
Block a user