Skip to content

Commit

Permalink
chore: Add a button to iOSSwift sample to start threads
Browse files Browse the repository at this point in the history
Added a button that will start 100 threads that will be alive for 10 seconds.
I believe is enough time to click any other button to try a feature with that many threads running.
  • Loading branch information
brustolin committed Mar 20, 2023
1 parent cd3bfeb commit f576153
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
</subviews>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="1a2-Yg-Az9">
<rect key="frame" x="181.5" y="0.0" width="216.5" height="360"/>
<rect key="frame" x="181.5" y="0.0" width="216.5" height="390"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Yi7-GN-26l">
<rect key="frame" x="0.0" y="0.0" width="216.5" height="30"/>
Expand Down Expand Up @@ -231,6 +231,14 @@
<action selector="unwrapCrash:" destination="BYZ-38-t0r" eventType="touchUpInside" id="qdc-Of-kqz"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hAC-fJ-9yK">
<rect key="frame" x="0.0" y="360" width="216.5" height="30"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Start 100 threads"/>
<connections>
<action selector="start100Threads:" destination="BYZ-38-t0r" eventType="touchUpInside" id="qDh-S4-Sib"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down Expand Up @@ -424,14 +432,14 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<navigationBar contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1SX-yg-zgj">
<rect key="frame" x="-1" y="0.0" width="414" height="44"/>
<rect key="frame" x="-1" y="0.0" width="413" height="44"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<items>
<navigationItem title="Hello" id="7le-ZX-hzV"/>
</items>
</navigationBar>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" fixedFrame="YES" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" delaysContentTouches="NO" editable="NO" adjustsFontForContentSizeCategory="YES" translatesAutoresizingMaskIntoConstraints="NO" id="sla-j3-cfX">
<rect key="frame" x="18" y="70" width="374" height="824"/>
<rect key="frame" x="18" y="70" width="374" height="823"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<color key="textColor" systemColor="labelColor"/>
Expand Down
8 changes: 8 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,14 @@ class ViewController: UIViewController {
}
}
}

@IBAction func start100Threads(_ sender: Any) {
for _ in 0..<100 {
Thread.detachNewThread {
Thread.sleep(forTimeInterval: 10)
}
}
}

private func calcPi() -> Double {
var denominator = 1.0
Expand Down

0 comments on commit f576153

Please sign in to comment.