Skip to content

Commit

Permalink
Merge branch 'runtime_select_event_loop' of github.com:awslabs/aws-c-…
Browse files Browse the repository at this point in the history
…io into grand_dispatch_queue
  • Loading branch information
xiazhvera committed Nov 25, 2024
2 parents 691aa17 + 53fc1fc commit 2461b43
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 56 deletions.
4 changes: 2 additions & 2 deletions include/aws/io/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ enum aws_socket_type {
*
* PLATFORM DEFAULT SOCKET IMPLEMENTATION TYPE
* Linux | AWS_SOCKET_IMPL_POSIX
* Windows | AWS_SOCKET_IMPL_WINSOCK
* Windows | AWS_SOCKET_IMPL_WINSOCK
* BSD Variants| AWS_SOCKET_IMPL_POSIX
* MacOS | AWS_SOCKET_IMPL_POSIX
* MacOS | AWS_SOCKET_IMPL_POSIX
* iOS | AWS_SOCKET_IMPL_APPLE_NETWORK_FRAMEWORK
*/
enum aws_socket_impl_type {
Expand Down
2 changes: 1 addition & 1 deletion source/windows/iocp/iocp_event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct aws_event_loop_vtable s_iocp_vtable = {
.free_io_event_resources = s_free_io_event_resources,
};

struct aws_event_loop *aws_event_loop_new_with_iocp_with_options(
struct aws_event_loop *aws_event_loop_new_with_iocp(
struct aws_allocator *alloc,
const struct aws_event_loop_options *options) {
AWS_ASSERT(alloc);
Expand Down
106 changes: 53 additions & 53 deletions tests/event_loop_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,59 +874,6 @@ static int s_state_wait_1sec(struct thread_tester *tester) {
}
}

/* Verify default event loop type */
static int s_test_event_loop_creation(
struct aws_allocator *allocator,
enum aws_event_loop_type type,
bool expect_success) {
struct aws_event_loop_options event_loop_options = {
.thread_options = NULL,
.clock = aws_high_res_clock_get_ticks,
.type = type,
};

struct aws_event_loop *event_loop = aws_event_loop_new(allocator, &event_loop_options);

if (expect_success) {
ASSERT_NOT_NULL(event_loop);
/* Clean up tester*/
aws_event_loop_destroy(event_loop);
} else {
ASSERT_NULL(event_loop);
}

return AWS_OP_SUCCESS;
}

/* Verify default event loop type */
static int s_test_event_loop_all_types_creation(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
bool enable_kqueue = false;
bool enable_epoll = false;
bool enable_iocp = false;
bool enable_dispatch_queue = false;
# ifdef AWS_ENABLE_KQUEUE
enable_kqueue = true;
# endif
# ifdef AWS_ENABLE_EPOLL
enable_epoll = true;
# endif
# ifdef AWS_ENABLE_IO_COMPLETION_PORTS
enable_iocp = true;
# endif
# ifdef AWS_ENABLE_DISPATCH_QUEUE
// TODO: Dispatch queue support is not yet implemented. Uncomment the following line once the dispatch queue is ready.
// enable_dispatch_queue = true;
# endif

return s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_EPOLL, enable_epoll) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_IOCP, enable_iocp) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_KQUEUE, enable_kqueue) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_DISPATCH_QUEUE, enable_dispatch_queue);
}

AWS_TEST_CASE(event_loop_all_types_creation, s_test_event_loop_all_types_creation)

/* Test that subscribe/unubscribe work at all */
static int s_test_event_loop_subscribe_unsubscribe(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
Expand Down Expand Up @@ -1038,6 +985,59 @@ AWS_TEST_CASE(event_loop_readable_event_on_2nd_time_readable, s_test_event_loop_

#endif /* AWS_ENABLE_IO_COMPLETION_PORTS */

/* Verify default event loop type */
static int s_test_event_loop_creation(
struct aws_allocator *allocator,
enum aws_event_loop_type type,
bool expect_success) {
struct aws_event_loop_options event_loop_options = {
.thread_options = NULL,
.clock = aws_high_res_clock_get_ticks,
.type = type,
};

struct aws_event_loop *event_loop = aws_event_loop_new(allocator, &event_loop_options);

if (expect_success) {
ASSERT_NOT_NULL(event_loop);
/* Clean up tester*/
aws_event_loop_destroy(event_loop);
} else {
ASSERT_NULL(event_loop);
}

return AWS_OP_SUCCESS;
}

/* Verify default event loop type */
static int s_test_event_loop_all_types_creation(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
bool enable_kqueue = false;
bool enable_epoll = false;
bool enable_iocp = false;
bool enable_dispatch_queue = false;
#ifdef AWS_ENABLE_KQUEUE
enable_kqueue = true;
#endif
#ifdef AWS_ENABLE_EPOLL
enable_epoll = true;
#endif
#ifdef AWS_ENABLE_IO_COMPLETION_PORTS
enable_iocp = true;
#endif
#ifdef AWS_ENABLE_DISPATCH_QUEUE
// TODO: Dispatch queue support is not yet implemented. Uncomment the following line once the dispatch queue is ready.
// enable_dispatch_queue = true;
#endif

return s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_EPOLL, enable_epoll) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_IOCP, enable_iocp) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_KQUEUE, enable_kqueue) ||
s_test_event_loop_creation(allocator, AWS_EVENT_LOOP_DISPATCH_QUEUE, enable_dispatch_queue);
}

AWS_TEST_CASE(event_loop_all_types_creation, s_test_event_loop_all_types_creation)

static int s_event_loop_test_stop_then_restart(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
struct aws_event_loop *event_loop = aws_event_loop_new_default(allocator, aws_high_res_clock_get_ticks);
Expand Down
1 change: 1 addition & 0 deletions tests/socket_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ static int s_test_socket_creation(struct aws_allocator *alloc, enum aws_socket_i
}

static int s_test_socket_impl_types_creation(struct aws_allocator *allocator, void *ctx) {
(void)ctx;
int posix_expected_result = AWS_ERROR_PLATFORM_NOT_SUPPORTED;
int winsock_expected_result = AWS_ERROR_PLATFORM_NOT_SUPPORTED;
#if defined(AWS_ENABLE_KQUEUE) || defined(AWS_ENABLE_EPOLL)
Expand Down

0 comments on commit 2461b43

Please sign in to comment.