summaryrefslogtreecommitdiffstats
path: root/src/vlib/global_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib/global_funcs.h')
-rw-r--r--src/vlib/global_funcs.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/vlib/global_funcs.h b/src/vlib/global_funcs.h
index 9dd01fbfb0d..b1d636f7ce4 100644
--- a/src/vlib/global_funcs.h
+++ b/src/vlib/global_funcs.h
@@ -19,15 +19,33 @@
#ifndef included_vlib_global_funcs_h_
#define included_vlib_global_funcs_h_
+always_inline u32
+vlib_get_n_threads ()
+{
+ return vec_len (vlib_mains);
+}
+
always_inline vlib_main_t *
-vlib_get_main (void)
+vlib_get_main_by_index (u32 thread_index)
{
vlib_main_t *vm;
- vm = vlib_mains[vlib_get_thread_index ()];
+ vm = vlib_mains[thread_index];
ASSERT (vm);
return vm;
}
+always_inline vlib_main_t *
+vlib_get_main (void)
+{
+ return vlib_get_main_by_index (vlib_get_thread_index ());
+}
+
+always_inline vlib_main_t *
+vlib_get_first_main (void)
+{
+ return vlib_get_main_by_index (0);
+}
+
always_inline vlib_thread_main_t *
vlib_get_thread_main ()
{