Skip to content

Commit

Permalink
Unlink shutdown callback from ref count (#1166)
Browse files Browse the repository at this point in the history
Co-authored-by: Bret Ambrose <[email protected]>
  • Loading branch information
bretambrose and Bret Ambrose authored Nov 12, 2024
1 parent bb29dc8 commit 257c9ec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
8 changes: 1 addition & 7 deletions include/aws/common/ref_count.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
#include <aws/common/common.h>

#include <aws/common/atomics.h>
#include <aws/common/shutdown_types.h>

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++
*/
Expand All @@ -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

/**
Expand Down
34 changes: 34 additions & 0 deletions include/aws/common/shutdown_types.h
Original file line number Diff line number Diff line change
@@ -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/common/common.h>

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 */

0 comments on commit 257c9ec

Please sign in to comment.