diff --git a/extra/exports b/extra/exports index 07a6dd8937e0d8b7b473e11394ac1983e56a4a02..a7c9d69ad9037a0e903ceaa4e6dd122f0b116eab 100644 --- a/extra/exports +++ b/extra/exports @@ -184,6 +184,8 @@ console_set_output_format cord_ibuf_drop cord_ibuf_put cord_ibuf_take +cord_is_main +cord_is_main_dont_create cord_slab_cache crc32_calc crypto_ERR_error_string @@ -213,6 +215,7 @@ csv_feed csv_iterator_create csv_next csv_setopt +current_cord_name decimal_from_string decimal_unpack error_find_field diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c index 6e1a8e1ee2222bf601d63feb5569722cd0b7fc58..95335a6271587bfdf554bcc7e6015a7604ccc7ba 100644 --- a/src/lib/core/fiber.c +++ b/src/lib/core/fiber.c @@ -2203,6 +2203,20 @@ cord_is_main(void) return cord() == &main_cord; } +bool +cord_is_main_dont_create(void) +{ + return cord_ptr == &main_cord; +} + +const char * +current_cord_name(void) +{ + if (cord_ptr == NULL) + return NULL; + return cord_name(cord_ptr); +} + struct slab_cache * cord_slab_cache(void) { diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h index afe8c2dba846e5536acc768c78672b6ac471b317..ad532e38396c6be122ef5221930d4f2e3ed49acb 100644 --- a/src/lib/core/fiber.h +++ b/src/lib/core/fiber.h @@ -949,10 +949,21 @@ cord_name(struct cord *cord) return cord->name; } +/** @return a current cord name. */ +API_EXPORT const char * +current_cord_name(void); + /** True if this cord represents the process main thread. */ bool cord_is_main(void); +/** + * Like `cord_is_main` but without creating a new cord + * if it doesn't exists. + */ +API_EXPORT bool +cord_is_main_dont_create(void); + /** * Delete the latest garbage fiber which couldn't be deleted somewhy before. Can * safely rely on the fiber being not the current one. Because if it was added