WIP: Added plumbing for descriptor class clash handling

This commit is contained in:
Tristan B. Velloza Kildaire 2022-01-12 17:47:50 +02:00
parent 63db311cdd
commit 934852c2a8
1 changed files with 25 additions and 4 deletions

View File

@ -15,6 +15,8 @@ import tasky.exceptions : TaskyException;
*/
public class Job
{
/* TODO: Static (and gsharea cross threads) ID tracker */
private this(Descriptor jobType, byte[] payload)
{
/* TODO: Extract needed information from here */
@ -31,6 +33,17 @@ public class Job
return new Job(jobType, payload);
}
/**
* Checks whether a Descriptor class has been registered
* previously that has the same ID but not the same
* equality (i.e. not spawned from the same object)
*/
public static bool isDescriptorClass(Descriptor descriptor)
{
/* TODO: Add the implementation for this */
return false;
}
}
public final class JobException : TaskyException
@ -58,6 +71,13 @@ public abstract class Descriptor
final this(ulong descriptorClass)
{
this.descriptorClass = descriptorClass;
/* TODO: Call descriotor class checker */
if(Job.isDescriptorClass(this))
{
throw new JobException("Descriptor class ID already in use by another descriptor");
}
}
/**
@ -69,13 +89,14 @@ public abstract class Descriptor
{
Job instantiatedDescriptor;
if(payload.length == 0)
{
throw new Exception("JobSpawnError: Empty payloads not allowed");
throw new JobException("JobSpawnError: Empty payloads not allowed");
}
else
{
instantiatedDescriptor = new Job(this, payload);
}
return instantiatedDescriptor;
}