You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
486 B

5 years ago
2 years ago
5 years ago
  1. //
  2. // DispatchQueue+Extensions.swift
  3. // Platform
  4. //
  5. // Created by Krunoslav Zaher on 10/22/16.
  6. // Copyright © 2016 Krunoslav Zaher. All rights reserved.
  7. //
  8. import Dispatch
  9. extension DispatchQueue {
  10. private static var token: DispatchSpecificKey<()> = {
  11. let key = DispatchSpecificKey<()>()
  12. DispatchQueue.main.setSpecific(key: key, value: ())
  13. return key
  14. }()
  15. static var isMain: Bool {
  16. DispatchQueue.getSpecific(key: token) != nil
  17. }
  18. }