From 257c9ec5f30d0aadfdf0064aa22265a9cdb97adf Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Tue, 12 Nov 2024 08:57:20 -0800 Subject: [PATCH] Unlink shutdown callback from ref count (#1166) Co-authored-by: Bret Ambrose --- include/aws/common/ref_count.h | 8 +------ include/aws/common/shutdown_types.h | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 include/aws/common/shutdown_types.h diff --git a/include/aws/common/ref_count.h b/include/aws/common/ref_count.h index 5166eb3f3..43fbde5e5 100644 --- a/include/aws/common/ref_count.h +++ b/include/aws/common/ref_count.h @@ -8,11 +8,10 @@ #include #include +#include AWS_PUSH_SANE_WARNING_LEVEL -typedef void(aws_simple_completion_callback)(void *); - /* * A utility type for making ref-counted types, reminiscent of std::shared_ptr in C++ */ @@ -22,11 +21,6 @@ struct aws_ref_count { aws_simple_completion_callback *on_zero_fn; }; -struct aws_shutdown_callback_options { - aws_simple_completion_callback *shutdown_callback_fn; - void *shutdown_callback_user_data; -}; - AWS_EXTERN_C_BEGIN /** diff --git a/include/aws/common/shutdown_types.h b/include/aws/common/shutdown_types.h new file mode 100644 index 000000000..4ade53a0c --- /dev/null +++ b/include/aws/common/shutdown_types.h @@ -0,0 +1,34 @@ +#ifndef AWS_COMMON_SHUTDOWN_TYPES_H +#define AWS_COMMON_SHUTDOWN_TYPES_H + +/** + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +#include + +AWS_PUSH_SANE_WARNING_LEVEL + +typedef void(aws_simple_completion_callback)(void *); + +/** + * Configuration for a callback to invoke when something has been completely + * cleaned up. Primarily used in async cleanup control flows. + */ +struct aws_shutdown_callback_options { + + /** + * Function to invoke when the associated object is fully destroyed. + */ + aws_simple_completion_callback *shutdown_callback_fn; + + /** + * User data to invoke the shutdown callback with. + */ + void *shutdown_callback_user_data; +}; + +AWS_POP_SANE_WARNING_LEVEL + +#endif /* AWS_COMMON_SHUTDOWN_TYPES_H */