 import UIKit
 
 
+private func async_main_safe(block: () -> Void) {
+    
+    if NSThread.isMainThread() {
+        block()
+    } else {
+        dispatch_async(dispatch_get_main_queue(), block)
+    }
+}
+
 protocol TableElementProtocol: NSObjectProtocol {
 
     class var identifier: String { get }


    private var animating: Bool = true

    /**
    :param: responder <#responder description#>
    :param: section   <#section description#>
    */
    public required init(responder: UIResponder?, section: TableSection = TableSection()) {
        self.responder = responder
        
        super.init()

        section.controller = self
        self.sections = [section]
    }

    deinit {

    }
    
    public func invalidate() {
    
        async_main_safe {
            self.updateWithoutAnimate()
        }
    }
