- Moved `Watcher` and `Manager` modules to their own package

- Ensured `Watcher`'s constructor is package-level accessible only

Manager

- The constructor now creates an instance of `Watcher`
- Added a `start()` method which calls `watcher.start()`
This commit is contained in:
Tristan B. Velloza Kildaire 2023-03-26 18:31:52 +02:00
parent 88432ab8d5
commit ed68bf7cd6
4 changed files with 17 additions and 6 deletions

View File

@ -1,12 +1,12 @@
/**
* Management of a tristanable instance
*/
module tristanable.manager;
module tristanable.manager.manager;
import std.socket;
import tristanable.queue : Queue;
import core.sync.mutex : Mutex;
import tristanable.watcher : Watcher;
import tristanable.manager.watcher : Watcher;
/**
* Manages a provided socket by spawning
@ -49,6 +49,14 @@ public class Manager
{
this.socket = socket;
this.queuesLock = new Mutex();
this.watcher = new Watcher(this, socket);
}
// TODO: comment
// Starts the watcher
public void start()
{
watcher.start();
}

View File

@ -0,0 +1,3 @@
module tristanable.manager;
public import tristanable.manager.manager : Manager;

View File

@ -1,7 +1,7 @@
module tristanable.watcher;
module tristanable.manager.watcher;
import core.thread : Thread;
import tristanable.manager : Manager;
import tristanable.manager.manager : Manager;
import std.socket;
/**
@ -27,7 +27,7 @@ public class Watcher : Thread
// TODO: make package-level in a way such
// ... that only Manager can access this constructor
// TODO: Add constructor doc
this(Manager manager, Socket socket)
package this(Manager manager, Socket socket)
{
this.manager = manager;
this.socket = socket;

View File

@ -7,7 +7,7 @@ module tristanable;
* Interface which manages a provided socket
* and enqueuing and dequeuing of queues
*/
public import tristanable.manager : Manager;
public import tristanable.manager;
// TODO: In future make `QueueItem` just `TaggedMessage`
/**