Changeset b5497ef


Ignore:
Timestamp:
Sep 30, 2018 11:02:28 AM (18 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
410f9df
Parents:
2233f7f
Message:

Mac OSX Launcher: Cancel stream that can cause high cpu load on router stop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/I2PLauncher/userinterface/LogViewController.swift

    r2233f7f rb5497ef  
    3737      let output = self.outputPipe?.fileHandleForReading.availableData
    3838      let outputString = String(data: output!, encoding: String.Encoding.utf8) ?? ""
    39      
    40       DispatchQueue.main.async(execute: {
     39      let workTask = DispatchWorkItem {
    4140        let previousOutput = self.textFieldView?.string ?? ""
    4241        let nextOutput = previousOutput + "\n" + outputString
     
    4544        let range = NSRange(location:nextOutput.characters.count,length:0)
    4645        self.textFieldView?.scrollRangeToVisible(range)
    47        
     46      }
     47      DispatchQueue.main.async(execute: workTask)
     48     
     49      // When router stop, stop the stream as well. If not it will go wild and create high cpu load
     50      RouterManager.shared().eventManager.listenTo(eventName: "router_stop", action: {
     51        NSLog("Time to cancel stream!")
     52        workTask.cancel()
    4853      })
     54     
    4955     
    5056      self.outputPipe?.fileHandleForReading.waitForDataInBackgroundAndNotify()
Note: See TracChangeset for help on using the changeset viewer.