Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aio: multishot operations #7

Open
Cloudef opened this issue Jul 24, 2024 · 1 comment
Open

aio: multishot operations #7

Cloudef opened this issue Jul 24, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Cloudef
Copy link
Owner

Cloudef commented Jul 24, 2024

It's possible to have multishot operations that take a callback parameter. These are important for repeating timers and socket accept loops. Should not need any special interface, but there might be some lifetime shenanigans that has to be taken in account.

@Cloudef
Copy link
Owner Author

Cloudef commented Jul 24, 2024

How it could work:

fn acceptCallback(context: *anyopaque, socket: std.posix.socket_t, addr: std.posix.addrinfo) !void {
    // cancel from inside a callback
    return error.Canceled;
}

var id: aio.Id = undefined;
try io.single(aio.AcceptMultishot{ .callback = acceptCallback, .context = arg, .out_id = &id });
// cancel from outside the callback
io.single(aio.Cancel{ .id = id });

@Cloudef Cloudef added the enhancement New feature or request label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant