- 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:
parent
88432ab8d5
commit
ed68bf7cd6
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module tristanable.manager;
|
||||
|
||||
public import tristanable.manager.manager : Manager;
|
|
@ -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;
|
|
@ -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`
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue