return TRUE;
}
+METHOD(stroke_counter_t, print, void,
+ private_stroke_counter_t *this, FILE *out)
+{
+ u_int64_t counter[COUNTER_MAX];
+ int i;
+
+ /* Take a snapshot to have congruent results, */
+ this->lock->lock(this->lock);
+ for (i = 0; i < countof(this->counter); i++)
+ {
+ counter[i] = this->counter[i];
+ }
+ this->lock->unlock(this->lock);
+
+ /* but do blocking write without the lock. */
+ for (i = 0; i < countof(this->counter); i++)
+ {
+ fprintf(out, "%-18N %12llu\n", stroke_counter_type_names, i, counter[i]);
+ }
+}
+
METHOD(stroke_counter_t, destroy, void,
private_stroke_counter_t *this)
{
.child_rekey = _child_rekey,
.message = _message_hook,
},
+ .print = _print,
.destroy = _destroy,
},
.lock = spinlock_create(),
listener_t listener;
/**
+ * Print counter values to an output stream.
+ *
+ * @param out output stream to write to
+ */
+ void (*print)(stroke_counter_t *this, FILE *out);
+
+ /**
* Destroy a stroke_counter_t.
*/
void (*destroy)(stroke_counter_t *this);