We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Thread.stackSize
1 parent eef6f00 commit 9db5b82Copy full SHA for 9db5b82
Sources/Foundation/Thread.swift
@@ -335,10 +335,16 @@ open class Thread : NSObject {
335
#if os(Windows)
336
open var stackSize: Int {
337
get {
338
+ // If we set a stack size for this thread.
339
+ // Otherwise, query the actual limits.
340
+ guard _attr.dwThreadStackReservation == 0 else {
341
+ return Int(_attr.dwThreadStackReservation)
342
+ }
343
var ulLowLimit: ULONG_PTR = 0
344
var ulHighLimit: ULONG_PTR = 0
345
GetCurrentThreadStackLimits(&ulLowLimit, &ulHighLimit)
- return Int(ulLowLimit)
346
+ // Return the reserved stack span.
347
+ return Int(ulHighLimit - ulLowLimit)
348
}
349
set {
350
_attr.dwThreadStackReservation = DWORD(newValue)
0 commit comments