зеркало из https://github.com/mozilla/glean.git
Bug 1552511 - Use finalizers to destruct metrics (#77)
Bug 1552511 - Use finalizers to destruct metrics
This commit is contained in:
Коммит
bb9ead2256
|
@ -9,6 +9,7 @@ import com.sun.jna.StringArray
|
|||
import mozilla.telemetry.glean.Glean
|
||||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
import mozilla.telemetry.glean.rust.RustError
|
||||
|
||||
class BooleanMetricType(
|
||||
disabled: Boolean,
|
||||
|
@ -32,6 +33,13 @@ class BooleanMetricType(
|
|||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
protected fun finalize() {
|
||||
if (this.handle != 0L) {
|
||||
val error = RustError.ByReference()
|
||||
LibGleanFFI.INSTANCE.glean_destroy_boolean_metric(this.handle, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a boolean value.
|
||||
*
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.sun.jna.StringArray
|
|||
import mozilla.telemetry.glean.Glean
|
||||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
import mozilla.telemetry.glean.rust.RustError
|
||||
|
||||
import mozilla.telemetry.glean.Dispatchers
|
||||
import mozilla.telemetry.glean.rust.toBoolean
|
||||
|
@ -50,6 +51,13 @@ class CounterMetricType(
|
|||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
protected fun finalize() {
|
||||
if (this.handle != 0L) {
|
||||
val error = RustError.ByReference()
|
||||
LibGleanFFI.INSTANCE.glean_destroy_counter_metric(this.handle, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add to counter value.
|
||||
*
|
||||
|
|
|
@ -10,6 +10,7 @@ import mozilla.telemetry.glean.Glean
|
|||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
import mozilla.telemetry.glean.rust.getAndConsumeRustString
|
||||
import mozilla.telemetry.glean.rust.RustError
|
||||
|
||||
import mozilla.telemetry.glean.Dispatchers
|
||||
import mozilla.telemetry.glean.rust.toBoolean
|
||||
|
@ -50,6 +51,13 @@ class StringMetricType(
|
|||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
protected fun finalize() {
|
||||
if (this.handle != 0L) {
|
||||
val error = RustError.ByReference()
|
||||
LibGleanFFI.INSTANCE.glean_destroy_string_metric(this.handle, error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a string value.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче