Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions std/concurrency.d
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,11 @@ bool receiveTimeout(T...)( long ms, T ops )
return mbox.get( ms * TICKS_PER_MILLI, ops );
}

/++ ditto +/
bool receiveTimeout(T...)( Duration duration, T ops )
{
return receiveTimeout(duration.total!"msecs"(), ops);
}

unittest
{
Expand All @@ -519,6 +524,11 @@ unittest
{
receiveTimeout( 0, (int x) {}, (int x) {} );
} ) );

assert( __traits( compiles,
{
receiveTimeout( dur!"msecs"(10), (int x) {}, (Variant x) {} );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test here is a bit alembicated. What's wrong with

if (false) receiveTimeout( dur!"msecs"(10), (int x) {}, (Variant x) {} );

The code will have to compile.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about that too, but then I saw that all the tests in that unittest block are written like that. I guess Sean is the one who has to answer that question.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just copying how the other tests were written. I didn't think about it all that much. Though looking at them now, I would have written them as static asserts.

} ) );
}


Expand Down