Change Thread to be internal as we not expose it to the user

This commit is contained in:
Norman Maurer 2018-02-08 09:26:53 +01:00
parent 8ed8f73d9a
commit 71f179e63b
1 changed files with 4 additions and 4 deletions

View File

@ -19,7 +19,7 @@ private typealias ThreadBox = Box<ThreadBoxValue>
/// A Thread that executes some runnable block. /// A Thread that executes some runnable block.
/// ///
/// All methods exposed are thread-safe. /// All methods exposed are thread-safe.
public final class Thread { final class Thread {
/// The pthread_t used by this instance. /// The pthread_t used by this instance.
let pthread: pthread_t let pthread: pthread_t
@ -33,7 +33,7 @@ public final class Thread {
} }
/// Get current name of the `Thread` or `nil` if not set. /// Get current name of the `Thread` or `nil` if not set.
public var name: String? { var name: String? {
get { get {
// 64 bytes should be good enough as on linux the limit is usually 16 and its very unlikely a user will ever set something longer anyway. // 64 bytes should be good enough as on linux the limit is usually 16 and its very unlikely a user will ever set something longer anyway.
var chars: [CChar] = Array(repeating: 0, count: 64) var chars: [CChar] = Array(repeating: 0, count: 64)
@ -55,7 +55,7 @@ public final class Thread {
/// - arguments: /// - arguments:
/// - name: The name of the `Thread` or `nil` if no specific name should be set. /// - name: The name of the `Thread` or `nil` if no specific name should be set.
/// - body: The function to execute within the spawned `Thread`. /// - body: The function to execute within the spawned `Thread`.
public class func spawnAndRun(name: String? = nil, body: @escaping (Thread) -> Void) { class func spawnAndRun(name: String? = nil, body: @escaping (Thread) -> Void) {
// Unfortunally the pthread_create method take a different first argument depending on if its on linux or macOS, so ensure we use the correct one. // Unfortunally the pthread_create method take a different first argument depending on if its on linux or macOS, so ensure we use the correct one.
#if os(Linux) #if os(Linux)
var pt: pthread_t = pthread_t() var pt: pthread_t = pthread_t()
@ -98,7 +98,7 @@ public final class Thread {
} }
/// Returns `true` if the calling thread is the same as this one. /// Returns `true` if the calling thread is the same as this one.
public var isCurrent: Bool { var isCurrent: Bool {
return pthread_equal(pthread, pthread_self()) != 0 return pthread_equal(pthread, pthread_self()) != 0
} }
} }