//
//  DispatchQueue+Extension.swift
//  Lanu
//
//  Created by OneeChan on 2025/11/13.
//

import Foundation


extension DispatchQueue {
    func asyncIfNotGlobal(block: @escaping () -> Void) {
        if self != .global() {
            async {
                block()
            }
        } else {
            block()
        }
    }
    
    func asyncIfNotMain(block: @escaping () -> Void) {
        if self != .main {
            async {
                block()
            }
        } else {
            block()
        }
    }
}

func runOnMain(block: @escaping () -> Void) {
    if Thread.isMainThread {
        block()
    } else {
        DispatchQueue.main.async {
            block()
        }
    }
}
