- Attack and start a `Sequential` provider to the `Executor` in constructor
- Added `stop()` method which stops the tristanable manager and the provider associated with the executor

Client (unit tests)

- Hoist result from future
- Stop client at end
- Removed while loop
This commit is contained in:
Tristan B. Velloza Kildaire 2023-10-01 22:43:22 +02:00
parent d0e920c347
commit 177c8081e4
1 changed files with 19 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import davinci;
import tristanable;
import guillotine;
import guillotine.providers.sequential;
version(dbg)
{
@ -30,6 +31,7 @@ public class DanteClient
* Guillotine engine
*/
private Executor executor;
private Provider provider;
// TODO: We do this because maybe lookup DNS rather than Address and then decice
// ... on whetherto make a TLS stream or not
@ -67,8 +69,12 @@ public class DanteClient
/* Create a tristanable manager based on this */
this.manager = new Manager(connection);
/* Create a provider (for the executor) and start it */ // TODO: change later to multi-threaded one or something
this.provider = new Sequential();
this.provider.start();
/* Create a task executor */
this.executor = new Executor();
this.executor = new Executor(this.provider);
}
public void start()
@ -78,6 +84,15 @@ public class DanteClient
version(dbg) { writeln("Dante staretd tristanable manager..."); }
}
public void stop()
{
/* Stop the tristanable manager */
manager.stop();
/* Stop the task executor's provider */
provider.stop();
}
public Future nopRequest()
{
import davinci.c2s.test;
@ -122,8 +137,9 @@ unittest
Future fut = client.nopRequest();
writeln("Awaitinf future...");
fut.await();
Result res = fut.await();
writeln("Awaitinf future... [done]");
writeln("Future result: ", res.getValue().value.object);
while(true){}
client.stop();
}