summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2018-04-22 22:20:18 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2018-04-22 22:20:18 +0200
commit4ccf632ad4418114df0cd8460c7dd3a86c246f9d (patch)
treea7b4c49df918e812998074f3ff71b6ba1868d645
parent2c980f4627309b55a160dbe7fc17156201d9dde4 (diff)
feat(#12): Buffer instrumentation measurements
This change will make the simulator by default buffer all measurements of attached instruments to prevent strange situations where certain measurements are not recorded due to the processing running on another thread.
-rw-r--r--opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/instrumentation/Port.kt8
1 files changed, 3 insertions, 5 deletions
diff --git a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/instrumentation/Port.kt b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/instrumentation/Port.kt
index caa11761..880f9a15 100644
--- a/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/instrumentation/Port.kt
+++ b/opendc-core/src/main/kotlin/com/atlarge/opendc/simulator/instrumentation/Port.kt
@@ -13,15 +13,13 @@ interface Port<M> {
/**
* Install the given instrumentation device to produce a stream of measurements of type <code>T</code>.
*
- * The [ReceiveChannel] returned by this channel is by default unlimited, which means the channel buffers at most
- * one measurement, so that the receiver always gets the most recently sent element.
- * Back-to-send sent measurements are conflated – only the the most recently sent element is received, while
- * previously sent elements are lost.
+ * The [ReceiveChannel] returned by this channel is by default backed by an unlimited buffer
+ * (using [Channel.UNLIMITED]), which may induce unnecessary overhead.
*
* @param instrument The instrumentation device to install.
* @return A [ReceiveChannel] to which the of measurements produced by the instrument are published.
*/
- fun <T> install(instrument: Instrument<T, M>): ReceiveChannel<T> = install(Channel.CONFLATED, instrument)
+ fun <T> install(instrument: Instrument<T, M>): ReceiveChannel<T> = install(Channel.UNLIMITED, instrument)
/**
* Install the given instrumentation device to produce a stream of measurements of type code>T</code>.