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

Change dwmblocks to use an asynchronous approach to executing blocks #110

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

begone-prop
Copy link

This PR changes the way dwmblocks functions. Instead of sleeping and checking periodically if a blocks needs to be updated a POSIX interval timer is created for each block. On expiry of this timer a either a signal is sent to the process by the kernel that invokes the signal handler for that block or if the block is setup with a signal of 0 a new thread is spawned for the block which executes the command provided to said block.

The main process after setting up each timer simply calls pause() and waits for a delivery of a signal.

These changes should improve performance and reduce CPU usage.

The program now also needs to be linked with -lrt.

commands, instead of sleeping and checking in loop if its time to run a
command a POSIX interval timer is set. A signal is sent by the kernel on
each expiration of the timer thus invoking the signal handler for that
block. For blocks with a signal of 0 a thread is spawned instead of
delivery of a signal.
@begone-prop
Copy link
Author

begone-prop commented Nov 17, 2022

Also forgot to add that signal dispositions are now set up by sigaction() rather than signal().

@LukeSmithxyz
Copy link
Owner

Can't really tell you anything other than "doesn't work" at this point.

The program doesn't die, but ceases to update pretty frequently.

Haven't looked at the code.

@begone-prop
Copy link
Author

Strange, apart from some missing glyphs on my end everything seems to be working as expected.
Does the entire status bar fail to update or just individual blocks?

Regardless, I'll take another look and run some more tests. Thanks for the feedback.

@LukeSmithxyz
Copy link
Owner

The whole bar freezes. The freeze happens pretty consistently a second or so in if not immediately.

Sorry I can't be more helpful. I've tried disabling different modules and it doesn't seem to make a difference.

…y. In principle this

mutex was not needed since both dimensions of the array are known at
compile time, it's size does not change while running and updating the
output of blocks happens at different indexes which also don't change
the size of the array.
@begone-prop
Copy link
Author

Should be fixed now.

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.

2 participants