Skip to content

Commit

Permalink
eliminate event loop constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Nov 12, 2024
1 parent e22131a commit 51e2d5a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 32 deletions.
10 changes: 0 additions & 10 deletions include/aws/io/event_loop.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,6 @@ struct aws_event_loop *aws_event_loop_new_base(
AWS_IO_API
void aws_event_loop_clean_up_base(struct aws_event_loop *event_loop);

/**
* @internal - Don't use outside of testing.
*
* Creates an instance of the event loop implementation from the options.
*/
AWS_IO_API
struct aws_event_loop *aws_event_loop_new_with_options(
struct aws_allocator *alloc,
const struct aws_event_loop_options *options);

/**
* @internal - Don't use outside of testing.
*
Expand Down
4 changes: 1 addition & 3 deletions include/aws/io/private/event_loop_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ struct aws_event_loop *aws_event_loop_new_default(struct aws_allocator *alloc, a
* Please note the event loop type defined in the options will be ignored.
*/
AWS_IO_API
struct aws_event_loop *aws_event_loop_new_default_with_options(
struct aws_allocator *alloc,
const struct aws_event_loop_options *options);
struct aws_event_loop *aws_event_loop_new(struct aws_allocator *alloc, const struct aws_event_loop_options *options);

/**
* Initializes common event-loop data structures.
Expand Down
20 changes: 3 additions & 17 deletions source/event_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,12 @@ struct aws_event_loop *aws_event_loop_new_default(struct aws_allocator *alloc, a
.type = AWS_EVENT_LOOP_PLATFORM_DEFAULT,
};

return aws_event_loop_new_with_options(alloc, &options);
}

struct aws_event_loop *aws_event_loop_new_default_with_options(
struct aws_allocator *alloc,
const struct aws_event_loop_options *options) {
struct aws_event_loop_options local_options = {
.thread_options = options->thread_options,
.clock = options->clock,
.type = AWS_EVENT_LOOP_PLATFORM_DEFAULT,
};

return aws_event_loop_new_with_options(alloc, &local_options);
return aws_event_loop_new(alloc, &options);
}

static enum aws_event_loop_type aws_event_loop_get_default_type(void);
static int aws_event_loop_type_validate_platform(enum aws_event_loop_type type);
struct aws_event_loop *aws_event_loop_new_with_options(
struct aws_allocator *alloc,
const struct aws_event_loop_options *options) {
struct aws_event_loop *aws_event_loop_new(struct aws_allocator *alloc, const struct aws_event_loop_options *options) {

enum aws_event_loop_type type = options->type;
if (type == AWS_EVENT_LOOP_PLATFORM_DEFAULT) {
Expand Down Expand Up @@ -246,7 +232,7 @@ static struct aws_event_loop *s_default_new_event_loop(
void *user_data) {

(void)user_data;
return aws_event_loop_new_default_with_options(allocator, options);
return aws_event_loop_new(allocator, options);
}

struct aws_event_loop_group *aws_event_loop_group_new(
Expand Down
2 changes: 1 addition & 1 deletion tests/socket_handler_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ static struct aws_event_loop *s_default_new_event_loop(
void *user_data) {

(void)user_data;
return aws_event_loop_new_default_with_options(allocator, options);
return aws_event_loop_new(allocator, options);
}

static int s_statistic_test_clock_fn(uint64_t *timestamp) {
Expand Down
2 changes: 1 addition & 1 deletion tests/tls_handler_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,7 @@ static struct aws_event_loop *s_default_new_event_loop(
void *user_data) {

(void)user_data;
return aws_event_loop_new_default_with_options(allocator, options);
return aws_event_loop_new(allocator, options);
}

static int s_statistic_test_clock_fn(uint64_t *timestamp) {
Expand Down

0 comments on commit 51e2d5a

Please sign in to comment.