Merge pull request #2 from deavmi/hotfix/composed_thread_for_udp

Composed thread
This commit is contained in:
Tristan B. Velloza Kildaire 2023-09-22 17:57:29 +02:00 committed by GitHub
commit 013886c79f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,13 +25,18 @@ import std.socket : Socket, Address, SocketType, ProtocolType, getAddress, parse
* Handles the actual sending and receiving * Handles the actual sending and receiving
* of datagrams and fulfilling of requests * of datagrams and fulfilling of requests
*/ */
class CoapMessagingLayer : Thread class CoapMessagingLayer
{ {
/** /**
* The client * The client
*/ */
private CoapClient client; private CoapClient client;
/**
* Reading-loop thread
*/
private Thread readingThread;
/** /**
* Running status * Running status
*/ */
@ -51,7 +56,6 @@ class CoapMessagingLayer : Thread
*/ */
this(CoapClient client) this(CoapClient client)
{ {
super(&loop);
this.client = client; this.client = client;
} }
@ -84,9 +88,9 @@ class CoapMessagingLayer : Thread
// this.socket.blocking(true); // this.socket.blocking(true);
this.socket.connect(getEndpointAddress()); this.socket.connect(getEndpointAddress());
// Create the reading-loop thread and start it
// Start the thread (TODO: In future hide threading) this.readingThread = new Thread(&loop);
this.start(); this.readingThread.start();
} }
/** /**
@ -124,7 +128,7 @@ class CoapMessagingLayer : Thread
this.socket.close(); this.socket.close();
// Wait till the reading-loop thread exits // Wait till the reading-loop thread exits
this.join(); this.readingThread.join();
} }
/** /**