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

Udev monitor improvements #8

Merged

Conversation

Apteryks
Copy link
Contributor

Fixes #5.

* modules/udev/monitor.scm (make-udev-monitor): Apply
udev-monitor-set-error-callback! to the error-callback default procedure, no
the callback one.
* libguile-udev/udev-monitor-func.c (udev_monitor_scanner): Fix typo.
Previously, it would default to use a 0 s timeout, which for select means that
it doesn't block (it would poll continuously and waste CPU).  This change
unifies the make-udev-monitor/udev-monitor-set-timeout! interface with that of
Guile's select procedure.

* NEWS: Update news.
* doc/guile-udev.texi (API Reference): Update doc.
* examples/device-listener.scm (main)
<make-udev-monitor>: Remove timeout arguments.
* libguile-udev/udev-monitor-func.c
(udev-monitor-set-timeout!): Make timeout arguments optional.  Update doc.
Streamline definition, removing all arguments validation, which is now handled
by scm_select.
* libguile-udev/udev-monitor-func.c (select_args_data): New struct.
(call_select, false_on_exception): New procedures.
(udev_monitor_scanner): Replace C select call with scm_select call, adjusting
the rest accordingly.
* libguile-udev/udev-monitor-type.h: Replace timeout member with new 'secs'
and 'usecs' ones.
* libguile-udev/udev-monitor-type.c (gudev_monitor_to_scm): Set default values
of secs and usecs to SCM_BOOL_F.
* modules/udev/monitor.scm (make-udev-monitor): Do not specify default values
for filter, timeout-sec and timeout-usec keyword arguments.  Update doc.

Fixes: artyom-poptsov#5
Copy link
Owner

@artyom-poptsov artyom-poptsov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@artyom-poptsov artyom-poptsov merged commit 96751a6 into artyom-poptsov:master Dec 24, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

100% CPU usage when using default timeouts (0 sec and 0 usec)
2 participants