Future: Added addClass(ulong) to add a custom descriptor ID

This commit is contained in:
Tristan B. Velloza Kildaire 2022-05-24 19:32:44 +02:00
parent 2251a00284
commit 89347cb6d2
1 changed files with 41 additions and 2 deletions

View File

@ -242,10 +242,12 @@ public abstract class Descriptor : Signal
/**
* Creates a new Descriptor
*
* FIXME: What if we cannot get a valid ID? Throw an exception
*/
this()
{
/* Grab a descripor ID */
/* Grab a descriptor ID */
descriptorClass = addDescQueue();
/**
@ -256,6 +258,39 @@ public abstract class Descriptor : Signal
super([descriptorClass]);
}
/**
* Given a descriptor class this will attempt adding it,
* on failure false is returned, on sucess, true
*
* NOTE: New feature, not yet in use
*/
private bool addClass(ulong descriptorClass)
{
bool status;
descQueueLock.lock();
/* Check if we can add it */
if(!isDescIDInUse(descriptorClass))
{
/* Add it to the ID queue */
descQueue ~= descriptorClass;
/* Set status to successful */
status = true;
}
else
{
/* Set status to failure */
status = false;
}
descQueueLock.unlock();
return status;
}
/**
* Creates a new Descriptor (with a given fixed descriptor class)
*
@ -263,7 +298,11 @@ public abstract class Descriptor : Signal
*/
this(ulong descriptorClass)
{
/* TODO: Check if it is available */
/* Check if the given descriptor class is available */
if(isDescIDInUse(descriptorClass))
{
/* TODO: This is a bad idea, we need to lock and one shot this */
}
/* TODO: Add to queue */
/* Set the descriptor ID */