diff mbox series

[ovs-dev,2/7] stopwatch: expose required api for event library

Message ID 4649bf8c47b75d7821567a2470dcd9dc20870922.1591091223.git.gmuthukr@redhat.com
State New
Headers show
Series user defined events and notification | expand

Commit Message

Gowrishankar Muthukrishnan June 2, 2020, 10:09 a.m. UTC
Timer notifications in event library require handling stopwatch
across one or more events, so share few required functions.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukr@redhat.com>
---
 lib/stopwatch.c | 20 +++++++++++++++++++-
 lib/stopwatch.h |  9 +++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/stopwatch.c b/lib/stopwatch.c
index f560216..0858d72 100644
--- a/lib/stopwatch.c
+++ b/lib/stopwatch.c
@@ -463,7 +463,7 @@  stopwatch_thread(void *ign OVS_UNUSED)
     return NULL;
 }
 
-static void
+void
 stopwatch_exit(void)
 {
     struct shash_node *node, *node_next;
@@ -526,6 +526,24 @@  stopwatch_create(const char *name, enum stopwatch_units units)
 }
 
 void
+stopwatch_delete(const char *name)
+{
+    ovs_mutex_lock(&stopwatches_lock);
+    shash_find_and_delete(&stopwatches, name);
+    ovs_mutex_unlock(&stopwatches_lock);
+}
+
+unsigned int
+stopwatch_count(void)
+{
+    unsigned int n;
+    ovs_mutex_lock(&stopwatches_lock);
+    n = shash_count(&stopwatches);
+    ovs_mutex_unlock(&stopwatches_lock);
+    return n;
+}
+
+void
 stopwatch_start(const char *name, unsigned long long ts)
 {
     struct stopwatch_packet *pkt = stopwatch_packet_create(OP_START_SAMPLE);
diff --git a/lib/stopwatch.h b/lib/stopwatch.h
index 91abd64..2f8e56c 100644
--- a/lib/stopwatch.h
+++ b/lib/stopwatch.h
@@ -56,4 +56,13 @@  bool stopwatch_get_stats(const char *name, struct stopwatch_stats *stats);
 /* Block until all enqueued samples have been processed. */
 void stopwatch_sync(void);
 
+/* Delete stopwatch */
+void stopwatch_delete(const char *name);
+
+/* Count stopwatches */
+unsigned int stopwatch_count(void);
+
+/* Exit stopwatch */
+void stopwatch_exit(void);
+
 #endif /* stopwatch.h */