mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 19:25:41 +02:00
module/cpu: cleanup poll-interval
* man page: spell out ‘milliseconds’ * use a ‘static const’ variable for min_poll_interval, instead of a macro
This commit is contained in:
parent
c0e0702a6c
commit
1f25978eb4
2 changed files with 10 additions and 9 deletions
|
@ -31,8 +31,8 @@ total CPU usage.
|
||||||
| poll-interval
|
| poll-interval
|
||||||
: int
|
: int
|
||||||
: no
|
: no
|
||||||
: Refresh interval of the CPU usage stats in ms (default=500). Cannot
|
: Refresh interval of the CPU usage stats in milliseconds
|
||||||
be less then 500 ms
|
(default=500). Cannot be less then 500ms.
|
||||||
|
|
||||||
# EXAMPLES
|
# EXAMPLES
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
#define LOG_MODULE "cpu"
|
#define LOG_MODULE "cpu"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#define SMALLEST_INTERVAL 500
|
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
|
||||||
#include "../bar/bar.h"
|
#include "../bar/bar.h"
|
||||||
|
@ -22,6 +21,8 @@
|
||||||
#include "../particles/dynlist.h"
|
#include "../particles/dynlist.h"
|
||||||
#include "../plugin.h"
|
#include "../plugin.h"
|
||||||
|
|
||||||
|
static const long min_poll_interval = 500;
|
||||||
|
|
||||||
struct cpu_stats {
|
struct cpu_stats {
|
||||||
uint32_t *prev_cores_idle;
|
uint32_t *prev_cores_idle;
|
||||||
uint32_t *prev_cores_nidle;
|
uint32_t *prev_cores_nidle;
|
||||||
|
@ -276,19 +277,19 @@ from_conf(const struct yml_node *node, struct conf_inherit inherited)
|
||||||
const struct yml_node *c = yml_get_value(node, "content");
|
const struct yml_node *c = yml_get_value(node, "content");
|
||||||
|
|
||||||
return cpu_new(
|
return cpu_new(
|
||||||
interval == NULL ? SMALLEST_INTERVAL : yml_value_as_int(interval),
|
interval == NULL ? min_poll_interval : yml_value_as_int(interval),
|
||||||
conf_to_particle(c, inherited));
|
conf_to_particle(c, inherited));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
conf_verify_interval(keychain_t *chain, const struct yml_node *node)
|
conf_verify_poll_interval(keychain_t *chain, const struct yml_node *node)
|
||||||
{
|
{
|
||||||
if (!conf_verify_unsigned(chain, node))
|
if (!conf_verify_unsigned(chain, node))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (yml_value_as_int(node) < SMALLEST_INTERVAL) {
|
if (yml_value_as_int(node) < min_poll_interval) {
|
||||||
LOG_ERR("%s: interval value cannot be less than %d ms",
|
LOG_ERR("%s: interval value cannot be less than %ldms",
|
||||||
conf_err_prefix(chain, node), SMALLEST_INTERVAL);
|
conf_err_prefix(chain, node), min_poll_interval);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ static bool
|
||||||
verify_conf(keychain_t *chain, const struct yml_node *node)
|
verify_conf(keychain_t *chain, const struct yml_node *node)
|
||||||
{
|
{
|
||||||
static const struct attr_info attrs[] = {
|
static const struct attr_info attrs[] = {
|
||||||
{"poll-interval", false, &conf_verify_interval},
|
{"poll-interval", false, &conf_verify_poll_interval},
|
||||||
MODULE_COMMON_ATTRS,
|
MODULE_COMMON_ATTRS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue