On Friday, 10 November 2017 at 15:01:30 UTC, bauss wrote:
On Friday, 10 November 2017 at 14:36:03 UTC, DrCataclysm wrote:
On Friday, 10 November 2017 at 14:27:41 UTC, bauss wrote:
On Friday, 10 November 2017 at 14:13:26 UTC, DrCataclysm
wrote:
[...]
_client is allocated in the heap.
Socket accept(); returns the socket created from Socket
accepting().
Which is like below:
protected Socket accepting() pure nothrow
{
return new Socket;
}
thank you, i thought i was going mad.
It is working now. The problem was that the debugger in
eclipse ddt seems to completely broken. If i run it directly
from bash it is working.
One last question: is there a function in the std to wait for
a task to finish within a time limit?
Not an ideal solution, but should work: (I'm not aware of any
build-in solutions using Phobos' tasks.
```
static const timeLimit = 1000; // Wait for the task up to 1000
milliseconds
while (!task.done && timeLimit)
{
import core.time : Thread, dur;
Thread.sleep( dur!("msecs")(1) ); // Preventing the CPU to
go nuts
timeLimit--;
}
if (task.done)
{
auto value = task.yieldForce();
}
```
Could make it a function though:
```
bool yieldTimeLimit(Task)(Task task)
{
while (!task.done && timeLimit)
{
import core.time : Thread, dur;
Thread.sleep( dur!("msecs")(1) );
timeLimit--;
}
return task.done;
}
...
if (yieldTimeLimit(task))
{
auto value = task.yieldForce();
}
```
Pardon my brain fart.
The last bit should be:
```
bool yieldTimeLimit(Task)(Task task, size_t timeLimit)
{
while (!task.done && timeLimit)
{
import core.time : Thread, dur;
Thread.sleep( dur!("msecs")(1) );
timeLimit--;
}
return task.done;
}
...
if (task.yieldTimeLimit(1000)) // Waits 1000 milliseconds
{
auto value = task.yieldForce();
}
```