| 1 | #ifndef AWS_COMMON_PRIVATE_THREAD_SHARED_H |
| 2 | #define AWS_COMMON_PRIVATE_THREAD_SHARED_H |
| 3 | /** |
| 4 | * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 5 | * SPDX-License-Identifier: Apache-2.0. |
| 6 | */ |
| 7 | |
| 8 | #include <aws/common/thread.h> |
| 9 | |
| 10 | struct aws_linked_list; |
| 11 | struct aws_linked_list_node; |
| 12 | |
| 13 | /** |
| 14 | * Iterates a list of thread wrappers, joining against each corresponding thread, and freeing the wrapper once |
| 15 | * the join has completed. Do not hold the managed thread lock when invoking this function, instead swap the |
| 16 | * pending join list into a local and call this on the local. |
| 17 | * |
| 18 | * @param wrapper_list list of thread wrappers to join and free |
| 19 | */ |
| 20 | AWS_COMMON_API void aws_thread_join_and_free_wrapper_list(struct aws_linked_list *wrapper_list); |
| 21 | |
| 22 | /** |
| 23 | * Adds a thread (wrapper embedding a linked list node) to the global list of threads that have run to completion |
| 24 | * and need a join in order to know that the OS has truly finished with the thread. |
| 25 | * @param node linked list node embedded in the thread wrapper |
| 26 | */ |
| 27 | AWS_COMMON_API void aws_thread_pending_join_add(struct aws_linked_list_node *node); |
| 28 | |
| 29 | /** |
| 30 | * Initializes the managed thread system. Called during library init. |
| 31 | */ |
| 32 | AWS_COMMON_API void aws_thread_initialize_thread_management(void); |
| 33 | |
| 34 | /** |
| 35 | * Gets the current managed thread count |
| 36 | */ |
| 37 | AWS_COMMON_API size_t aws_thread_get_managed_thread_count(void); |
| 38 | |
| 39 | #endif /* AWS_COMMON_PRIVATE_THREAD_SHARED_H */ |