Merged in rnicoll-state-machine-id (pull request #234)

Add Fiber ID to state machine change events
This commit is contained in:
Ross Nicoll 2016-07-20 13:23:02 +01:00
commit 2c139ae40c
2 changed files with 6 additions and 5 deletions

View File

@ -89,13 +89,13 @@ class StateMachineManager(val serviceHub: ServiceHubInternal, tokenizableService
val allStateMachines: List<ProtocolLogic<*>>
get() = stateMachines.keys.map { it.logic }
private val _changesPublisher = PublishSubject.create<Pair<ProtocolLogic<*>, AddOrRemove>>()
private val _changesPublisher = PublishSubject.create<Triple<ProtocolLogic<*>, AddOrRemove, Long>>()
val changes: Observable<Pair<ProtocolLogic<*>, AddOrRemove>>
val changes: Observable<Triple<ProtocolLogic<*>, AddOrRemove, Long>>
get() = _changesPublisher
private fun notifyChangeObservers(psm: ProtocolStateMachineImpl<*>, change: AddOrRemove) {
_changesPublisher.onNext(Pair(psm.logic, change))
_changesPublisher.onNext(Triple(psm.logic, change, psm.id))
}
// Used to work around a small limitation in Quasar.

View File

@ -4,6 +4,7 @@ import com.r3corda.core.ThreadBox
import com.r3corda.core.protocols.ProtocolLogic
import com.r3corda.core.utilities.ProgressTracker
import com.r3corda.node.services.statemachine.StateMachineManager
import com.r3corda.protocols.TwoPartyDealProtocol
import java.util.*
/**
@ -13,7 +14,7 @@ import java.util.*
class ANSIProgressObserver(val smm: StateMachineManager) {
init {
smm.changes.subscribe { change: Pair<ProtocolLogic<*>, AddOrRemove> ->
smm.changes.subscribe { change: Triple<ProtocolLogic<*>, AddOrRemove, Long> ->
when (change.second) {
AddOrRemove.ADD -> addProtocolLogic(change.first)
AddOrRemove.REMOVE -> removeProtocolLogic(change.first)
@ -57,4 +58,4 @@ class ANSIProgressObserver(val smm: StateMachineManager) {
}
}
}
}
}