mirror of
https://github.com/deavmi/doap
synced 2024-07-04 14:50:54 +02:00
Merge pull request #2 from deavmi/hotfix/composed_thread_for_udp
Composed thread
This commit is contained in:
commit
013886c79f
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user