mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:27:34 +00:00
LibCore: IDAllocator should never vend ID 0
This was tripping up CObject which interprets timer ID 0 as "no timer". Once we got ID 0 assigned, it was impossible to turn it off and it would fire on every event loop iteration, causing CPU churn.
This commit is contained in:
parent
c410644c90
commit
1da31ce8ae
1 changed files with 3 additions and 0 deletions
|
@ -16,6 +16,9 @@ public:
|
||||||
int r = rand();
|
int r = rand();
|
||||||
for (int i = 0; i < 100000; ++i) {
|
for (int i = 0; i < 100000; ++i) {
|
||||||
int allocated_id = r + i;
|
int allocated_id = r + i;
|
||||||
|
// Make sure we never vend ID 0, as some code may interpret that as "no ID"
|
||||||
|
if (allocated_id == 0)
|
||||||
|
++allocated_id;
|
||||||
if (!m_allocated_ids.contains(allocated_id)) {
|
if (!m_allocated_ids.contains(allocated_id)) {
|
||||||
m_allocated_ids.set(allocated_id);
|
m_allocated_ids.set(allocated_id);
|
||||||
return allocated_id;
|
return allocated_id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue