Skip to content

Commit

Permalink
Merge pull request #67 from iZettle/fix-threadstate-leak
Browse files Browse the repository at this point in the history
Fix ThreadState never released when the thread gets closed
  • Loading branch information
egarni authored Dec 14, 2018
2 parents 66ad3b5 + c044bf2 commit c918722
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Flow/Scheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ var threadState: ThreadState {
private let mainThreadState = ThreadState()
private var _threadStateKey: pthread_key_t = 0
private var threadStateKey: pthread_key_t = {
pthread_key_create(&_threadStateKey, nil)
let cleanup: @convention(c) (UnsafeMutableRawPointer) -> Void = { state in
Unmanaged<ThreadState>.fromOpaque(state).release()
}
pthread_key_create(&_threadStateKey, cleanup)
return _threadStateKey
}()

0 comments on commit c918722

Please sign in to comment.