1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:58:11 +00:00
serenity/Servers/WindowServer/WSCPUMonitor.h
Andreas Kling bc6ac1c2f2 WindowServer: Let the CPU monitor keep /proc/all open between refreshes.
Just seek to the beginning on every iteration and start over. This avoids
a bunch of syscalls.
2019-04-15 23:57:31 +02:00

24 lines
511 B
C++

#pragma once
#include <AK/CircularQueue.h>
#include <stdio.h>
class Painter;
class Rect;
class WSCPUMonitor {
public:
WSCPUMonitor();
bool is_dirty() const { return m_dirty; }
void set_dirty(bool dirty) { m_dirty = dirty; }
int capacity() const { return m_cpu_history.capacity(); }
void paint(Painter&, const Rect&);
private:
void get_cpu_usage(unsigned& busy, unsigned& idle);
CircularQueue<float, 30> m_cpu_history;
FILE* m_fp { nullptr };
bool m_dirty { false };
};