static_threads.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef NETDATA_STATIC_THREADS_H
  3. #define NETDATA_STATIC_THREADS_H
  4. #include "common.h"
  5. struct netdata_static_thread {
  6. // the name of the thread as it should appear in the logs
  7. char *name;
  8. // the section of netdata.conf to check if this is enabled or not
  9. char *config_section;
  10. // the name of the config option to check if it is true or false
  11. char *config_name;
  12. // the current status of the thread
  13. volatile sig_atomic_t enabled;
  14. // internal use, to maintain a pointer to the created thread
  15. netdata_thread_t *thread;
  16. // an initialization function to run before spawning the thread
  17. void (*init_routine) (void);
  18. // the threaded worker
  19. void *(*start_routine) (void *);
  20. // the environment variable to create
  21. char *env_name;
  22. // global variable
  23. bool *global_variable;
  24. };
  25. #define NETDATA_MAIN_THREAD_RUNNING CONFIG_BOOLEAN_YES
  26. #define NETDATA_MAIN_THREAD_EXITING (CONFIG_BOOLEAN_YES + 1)
  27. #define NETDATA_MAIN_THREAD_EXITED CONFIG_BOOLEAN_NO
  28. extern const struct netdata_static_thread static_threads_common[];
  29. extern const struct netdata_static_thread static_threads_linux[];
  30. extern const struct netdata_static_thread static_threads_freebsd[];
  31. extern const struct netdata_static_thread static_threads_macos[];
  32. struct netdata_static_thread *
  33. static_threads_concat(const struct netdata_static_thread *lhs,
  34. const struct netdata_static_thread *rhs);
  35. struct netdata_static_thread *static_threads_get();
  36. #endif /* NETDATA_STATIC_THREADS_H */