summaryrefslogtreecommitdiff
path: root/iono/iono.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iono/iono.swift')
-rw-r--r--iono/iono.swift9
1 files changed, 5 insertions, 4 deletions
diff --git a/iono/iono.swift b/iono/iono.swift
index 1f07140..95feb5b 100644
--- a/iono/iono.swift
+++ b/iono/iono.swift
@@ -16,7 +16,7 @@
import Foundation
-public protocol IonoMessageHandler {
+public protocol IonoMessageHandler: AnyObject {
func handleMessage(message: String)
}
@@ -48,7 +48,7 @@ struct Queue<T> {
}
class NodeThread: Thread {
- var iono: Iono!
+ weak var iono: Iono!
var workQueue: Queue<() -> ()>
var initialized: Bool
var initCondition: NSCondition
@@ -98,9 +98,9 @@ public class Iono {
var thread: NodeThread
var instance: OpaquePointer!
- public var messageHandler: IonoMessageHandler?
+ public weak var messageHandler: IonoMessageHandler?
- public init() { // We need to be calling runNode!
+ public init() {
self.stopped = false
self.thread = NodeThread()
self.thread.iono = self
@@ -179,6 +179,7 @@ public class Iono {
evalNodeCode(source: source)
}
+ /// Note: This *must* be called before releasing the object, or else the thread will keep going.
public func waitStopped() {
scheduleNodeThreadSync {
self.stopped = true