LukeSmithxyz / dwmblocks

My status bar: my build of the modular dwmblocks
GNU General Public License v2.0
430 stars 368 forks source link

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

Open begone-prop opened 1 year ago

begone-prop commented 1 year ago

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.

begone-prop commented 1 year ago

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

LukeSmithxyz commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.

begone-prop commented 1 year ago

Should be fixed now.