esp_pthread.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. #include <pthread.h>
  18. /** pthread configuration structure that influences pthread creation */
  19. typedef struct {
  20. size_t stack_size; ///< the stack size of the pthread
  21. size_t prio; ///< the thread's priority
  22. bool inherit_cfg; ///< inherit this configuration further
  23. } esp_pthread_cfg_t;
  24. /**
  25. * @brief Configure parameters for creating pthread
  26. *
  27. * This API allows you to configure how the subsequent
  28. * pthread_create() call will behave. This call can be used to setup
  29. * configuration parameters like stack size, priority, configuration
  30. * inheritance etc.
  31. *
  32. * If the 'inherit' flag in the configuration structure is enabled,
  33. * then the same configuration is also inherited in the thread
  34. * subtree.
  35. *
  36. * @param cfg The pthread config parameters
  37. *
  38. * @return
  39. * - ESP_OK if configuration was successfully set
  40. * - ESP_ERR_NO_MEM if out of memory
  41. */
  42. esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg);
  43. /**
  44. * @brief Get current pthread creation configuration
  45. *
  46. * This will retrieve the current configuration that will be used for
  47. * creating threads.
  48. *
  49. * @param p Pointer to the pthread config structure that will be
  50. * updated with the currently configured parameters
  51. *
  52. * @return
  53. * - ESP_OK if the configuration was available
  54. * - ESP_ERR_NOT_FOUND if a configuration wasn't previously set
  55. */
  56. esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p);
  57. #ifdef __cplusplus
  58. }
  59. #endif