Skip to content

Allow watchers to generate completions without adding them to the loop. #123

Open
@bhansconnect

Description

@bhansconnect

This is a general design request. I think it would be nice to all the various watchers to fill out completions without adding them to a loop. I am working on a multithreaded system, where the main loop is behind lock. As such, I don't want threads to always lock due to calling loop.add. Instead it would be preferable to just create a completion. Later, the lock can be grabbed and loop.add called.

As such, it would be nice to have a version of the watcher functions that doesn't call loop.add. The simplest solution would be to change loop: *xev.Loop to a loop: ?*xev.Loop. If the loop is null, no add function is called. where be a modification here and in other equivalent functions:

loop.add(c);

to something like:

if (loop) |l| {
    l.add(c);
}

That said, it may be nicer to fully split out the api and make two different calls. One that just fills out the completion and one that actually adds to the loop.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions