record.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @file record.h
  3. * Furi: record API
  4. */
  5. #pragma once
  6. #include <stdbool.h>
  7. #include "core_defines.h"
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /** Initialize record storage For internal use only.
  12. */
  13. void furi_record_init();
  14. /** Check if record exists
  15. *
  16. * @param name record name
  17. * @note Thread safe. Create and destroy must be executed from the same
  18. * thread.
  19. */
  20. bool furi_record_exists(const char* name);
  21. /** Create record
  22. *
  23. * @param name record name
  24. * @param data data pointer
  25. * @note Thread safe. Create and destroy must be executed from the same
  26. * thread.
  27. */
  28. void furi_record_create(const char* name, void* data);
  29. /** Destroy record
  30. *
  31. * @param name record name
  32. *
  33. * @return true if successful, false if still have holders or thread is not
  34. * owner.
  35. * @note Thread safe. Create and destroy must be executed from the same
  36. * thread.
  37. */
  38. bool furi_record_destroy(const char* name);
  39. /** Open record
  40. *
  41. * @param name record name
  42. *
  43. * @return pointer to the record
  44. * @note Thread safe. Open and close must be executed from the same
  45. * thread. Suspends caller thread till record is available
  46. */
  47. FURI_RETURNS_NONNULL void* furi_record_open(const char* name);
  48. /** Close record
  49. *
  50. * @param name record name
  51. * @note Thread safe. Open and close must be executed from the same
  52. * thread.
  53. */
  54. void furi_record_close(const char* name);
  55. #ifdef __cplusplus
  56. }
  57. #endif