| 1 | """ |
| 2 | Cross-platform library for `awscrt`. |
| 3 | """ |
| 4 | import _awscrt |
| 5 | |
| 6 | |
| 7 | def get_cpu_group_count() -> int: |
| 8 | """ |
| 9 | Returns number of processor groups on the system. |
| 10 | |
| 11 | Useful for working with non-uniform memory access (NUMA) nodes. |
| 12 | """ |
| 13 | return _awscrt.get_cpu_group_count() |
| 14 | |
| 15 | |
| 16 | def get_cpu_count_for_group(group_idx: int) -> int: |
| 17 | """ |
| 18 | Returns number of processors in a given group. |
| 19 | """ |
| 20 | return _awscrt.get_cpu_count_for_group(group_idx) |
| 21 | |
| 22 | |
| 23 | def join_all_native_threads(*, timeout_sec: float = -1.0) -> bool: |
| 24 | """ |
| 25 | Waits for all native threads to complete their join call. |
| 26 | |
| 27 | This can only be safely called from the main thread. |
| 28 | This call may be required for native memory usage to reach zero. |
| 29 | |
| 30 | Args: |
| 31 | timeout_sec (float): Number of seconds to wait before a timeout exception is raised. |
| 32 | By default the wait is unbounded. |
| 33 | |
| 34 | Returns: |
| 35 | bool: Returns whether threads could be joined before the timeout. |
| 36 | """ |
| 37 | return _awscrt.thread_join_all_managed(timeout_sec) |