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

Cannot terminate while loops in blocking calls to open() #33

Open
halee88 opened this issue Sep 28, 2023 · 2 comments
Open

Cannot terminate while loops in blocking calls to open() #33

halee88 opened this issue Sep 28, 2023 · 2 comments

Comments

@halee88
Copy link

halee88 commented Sep 28, 2023

When launching a server, all plugins' losc:open() functions create an infinite loop without any way to exit it via code. Instead a user must forcefully terminate the lua runtime. This makes the server functionality impossible to embed in more complex applications.

A solution would be to enforce a 'non-blocking' requirement on each plugin and adapt the high-level api as necessary (see #32). Backwards compatibility with existing 'blocking' usages could be accomplished by adding a default blocking=true param to the losc:open() function

@davidgranstrom
Copy link
Owner

Yes, the plugins included are more or less "examples" on implementation and could definitely be improved for more use-cases. My original idea was that it would be up to the plugin if it would block or not on losc:open(), the function signature can vary depending on the plugin implementation so a blocking flag could be implemented for a specific plugin.

Here is an example of a non-blocking implementation using libuv: https://github.com/davidgranstrom/osc.nvim/blob/main/lua/osc/udp-transport.lua it is callback based though, but I like the idea in #32 of an additional losc:poll() function to handle non-callback based implementations.

@Simon-L
Copy link

Simon-L commented Sep 30, 2023

Hello! I made a quick attempt at adding the :poll() method in PR #34 :)

Interestingly I needed that feature yesterday and it's currently being discussed here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants