Compare commits

...

5 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire a51df3b699 Engine
- If a `Request` is not expecting a response then do not call `dequeue()` on the `Queue` registered nor `process`byte[])`
- Added a TODO comment
2023-05-04 14:17:35 +02:00
Tristan B. Velloza Kildaire 8387d0ee78 Request
- Implemented `expectsResponse()` which returns `false` if no response handler is assigned (implying no response is expected), `true` otherwise
2023-05-04 14:15:19 +02:00
Tristan B. Velloza Kildaire 7af21a909a Request
- Allow constructing WITHOUT a `ResponseHandler` (it remains as `null)
2023-05-04 11:04:32 +02:00
Tristan B. Velloza Kildaire 7072c852dc Request
- Removed now-completed TODO
2023-05-04 11:03:11 +02:00
Tristan B. Velloza Kildaire 93d6d49c20 - Clean up 2023-05-04 10:54:20 +02:00
4 changed files with 23 additions and 25 deletions

View File

@ -3,10 +3,9 @@ tasky
![](branding/logo.png)
## Creating a `Descriptor`
## What is it?
Before we can spawn any jobs one needs to first create a description
of the type of `Job` that will be spawned.
TODO: Describe here.
## Adding to your project

View File

@ -14,6 +14,8 @@ public class Engine
// TODO: Continue working on this
// TODO: Allow registering ResponseAnonymous with handlers etc
/**
* Takes a request and sends it through to the endpoint
* afterwhich we block for a response and when we get one
@ -35,11 +37,16 @@ public class Engine
/* Send the message */
tManager.sendMessage(tReq);
/* Await for a response */
byte[] resp = newQueue.dequeue().getPayload();
/* Does this Request expect a response? */
// TODO: We need not register the queue even if this is the case
if(req.expectsResponse())
{
/* Await for a response */
byte[] resp = newQueue.dequeue().getPayload();
/* Run the response handler with the response */
req.process(resp);
/* Run the response handler with the response */
req.process(resp);
}
/* De-register the queue */
tManager.releaseQueue(newQueue);

View File

@ -7,8 +7,6 @@ public alias ResponseHandler = void function(byte[]);
public abstract class Request
{
private byte[] requestMessage;
// TODO: Define the below with an alias for a function pointer that accepts a byte[] (the response data)
private ResponseHandler respFunc;
@ -18,6 +16,11 @@ public abstract class Request
this.respFunc = respFunc;
}
protected this(byte[] requestMessage)
{
this(requestMessage, null);
}
package final byte[] getRequestData()
{
return requestMessage;
@ -27,4 +30,9 @@ public abstract class Request
{
respFunc(responseData);
}
package final bool expectsResponse()
{
return respFunc !is null;
}
}

16
todo.md
View File

@ -1,16 +0,0 @@
# TODO
I think when we throw that session exception (even though that is the wrong) place,
by throwing we may throw it when the next queue we'd iterate to was filled and we looped
pver something flushed, but throw because invalid (now) queue operation
We should think about this and maybe chekc rather using a public, isAlice, and if so wthen finish up to try read as
much as possible from the queues even when socket is dead but THEN never loop again (kill the Tasky loop).
It is always passing, but I should consider the above as it is a possible case.
But I do have something hanging, I need to check what that is, I believe wait that may be tristanable threads etc, I don't think newSys is erroring correctly
It might with or without newSys be hanging, socket error shit fr do be annoying me, idk needs more testing.
wait no shit looks fine lmao, we are reaching `"Err"` which is good