From a63485b65b6b3367039306496d49737cf1995408 Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 13 Jun 2024 10:21:28 -0700 Subject: [PATCH] aws-crt-ffi v0.3.7 -> v0.3.8 (#112) Also: replace uses of `aws_promise` (removed in https://github.com/awslabs/aws-c-common/pull/1110) with `aws_future` --- crt/aws-crt-ffi | 2 +- ext/crt.c | 22 +++++++++++----------- ext/php_aws_crt.h | 6 +++--- ext/signing.c | 18 +++++++++--------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/crt/aws-crt-ffi b/crt/aws-crt-ffi index a266356..5dc37a6 160000 --- a/crt/aws-crt-ffi +++ b/crt/aws-crt-ffi @@ -1 +1 @@ -Subproject commit a266356369045bbac30610fa5979c79fad1468d0 +Subproject commit 5dc37a67cdbd2d117c402a951d61eed8ef3be70e diff --git a/ext/crt.c b/ext/crt.c index 128b234..57f7ac5 100644 --- a/ext/crt.c +++ b/ext/crt.c @@ -195,9 +195,9 @@ bool aws_php_thread_queue_drain(aws_php_thread_queue *queue) { } /* called on main thread after delivery */ -static void s_thread_queue_complete_promise(void *data) { - struct aws_promise *promise = data; - aws_promise_complete(promise, NULL, NULL); +static void s_thread_queue_complete_future(void *data) { + struct aws_future_void *future = data; + aws_future_void_set_result(future); } /* called from worker thread to wait for the main thread to execute any queued work in PHP */ @@ -206,21 +206,21 @@ void aws_php_thread_queue_yield(aws_php_thread_queue *queue) { if (aws_php_is_main_thread()) { aws_php_thread_queue_drain(queue); } else { - /* push a task onto the end of the queue, we will return once this task completes our promise */ - struct aws_promise *queue_drained = aws_promise_new(aws_crt_default_allocator()); + /* push a task onto the end of the queue, we will return once this task completes our future */ + struct aws_future_void *queue_drained = aws_future_void_new(aws_crt_default_allocator()); aws_php_task queue_drained_task = { - .callback = s_thread_queue_complete_promise, + .callback = s_thread_queue_complete_future, .data = queue_drained, }; aws_php_thread_queue_push(queue, queue_drained_task); - aws_promise_wait(queue_drained); - aws_promise_release(queue_drained); + aws_future_void_wait(queue_drained, UINT64_MAX /*timeout*/); + aws_future_void_release(queue_drained); } } -/* called from PHP thread to wait on async queued jobs, one of which should complete the promise */ -void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_promise *promise) { - while (!aws_promise_is_complete(promise)) { +/* called from PHP thread to wait on async queued jobs, one of which should complete the future */ +void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_future_void *future) { + while (!aws_future_void_is_done(future)) { aws_php_thread_queue_drain(queue); } } diff --git a/ext/php_aws_crt.h b/ext/php_aws_crt.h index 393e4b0..716a24e 100644 --- a/ext/php_aws_crt.h +++ b/ext/php_aws_crt.h @@ -17,8 +17,8 @@ #include #include -#include #include +#include /* ZEND_EXTENSION_API_NO from each branch of the PHP source */ #define AWS_PHP_EXTENSION_API_5_5 220121212 @@ -162,8 +162,8 @@ bool aws_php_thread_queue_drain(aws_php_thread_queue *queue); /* called from worker thread to wait for the main thread to execute any queued work in PHP */ void aws_php_thread_queue_yield(aws_php_thread_queue *queue); -/* called from PHP thread to wait on async queued jobs, one of which MUST complete the promise */ -void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_promise *promise); +/* called from PHP thread to wait on async queued jobs, one of which MUST complete the future */ +void aws_php_thread_queue_wait(aws_php_thread_queue *queue, struct aws_future_void *future); /** * generic dispatch mechanism to call a callback provided as a zval with arguments diff --git a/ext/signing.c b/ext/signing.c index 4e629d4..b9ff389 100644 --- a/ext/signing.c +++ b/ext/signing.c @@ -268,7 +268,7 @@ PHP_FUNCTION(aws_crt_signing_result_apply_to_http_request) { } typedef struct _signing_state { - struct aws_promise *promise; + struct aws_future_void *future; zval *on_complete; aws_crt_signing_result *signing_result; int error_code; @@ -284,7 +284,7 @@ static void s_sign_aws_complete(void *data) { /* called from signing process in aws_sign_request_aws */ static void s_on_sign_request_aws_complete(aws_crt_signing_result *result, int error_code, void *user_data) { signing_state *state = user_data; - struct aws_promise *promise = state->promise; + struct aws_future_void *future = state->future; state->signing_result = result; state->error_code = error_code; @@ -301,9 +301,9 @@ static void s_on_sign_request_aws_complete(aws_crt_signing_result *result, int e aws_php_thread_queue_yield(&s_aws_php_main_thread_queue); if (error_code) { - aws_promise_fail(promise, error_code); + aws_future_void_set_error(future, error_code); } else { - aws_promise_complete(promise, result, NULL); + aws_future_void_set_result(future); } } @@ -318,23 +318,23 @@ PHP_FUNCTION(aws_crt_sign_request_aws) { aws_crt_signable *signable = (void *)php_signable; aws_crt_signing_config_aws *signing_config = (void *)php_signing_config; - struct aws_promise *promise = aws_promise_new(aws_crt_default_allocator()); + struct aws_future_void *future = aws_future_void_new(aws_crt_default_allocator()); signing_state state = { - .promise = promise, + .future = future, .on_complete = php_on_complete, }; int ret = aws_crt_sign_request_aws(signable, signing_config, s_on_sign_request_aws_complete, &state); if (ret != 0) { int last_error = aws_crt_last_error(); - aws_promise_fail(promise, last_error); + aws_future_void_set_error(future, last_error); aws_php_throw_exception( "aws_crt_sign_request_aws: error starting signing process: %s", aws_crt_error_name(last_error)); } - aws_php_thread_queue_wait(&s_aws_php_main_thread_queue, promise); + aws_php_thread_queue_wait(&s_aws_php_main_thread_queue, future); done: - aws_promise_release(promise); + aws_future_void_release(future); RETURN_LONG(ret); }