Skip to content

Commit

Permalink
Remove some global imports from std.concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
JackStouffer committed Sep 21, 2016
1 parent 66f3456 commit 971da6a
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions std/concurrency.d
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,8 @@ private
import core.thread;
import core.sync.mutex;
import core.sync.condition;
import std.algorithm;
import std.exception;
import std.meta;
import std.range;
import std.string;
import std.range.primitives;
import std.traits;
import std.typecons;
import std.concurrencybase;

template hasLocalAliasing(T...)
Expand Down Expand Up @@ -120,17 +115,24 @@ private
this(T...)( MsgType t, T vals )
if ( T.length > 1 )
{
import std.typecons : Tuple;

type = t;
data = Tuple!(T)( vals );
}

@property auto convertsTo(T...)()
{
static if ( T.length == 1 )
{
return is( T[0] == Variant ) ||
data.convertsTo!(T);
}
else
{
import std.typecons : Tuple;
return data.convertsTo!(Tuple!(T));
}
}

@property auto get(T...)()
Expand All @@ -144,6 +146,7 @@ private
}
else
{
import std.typecons : Tuple;
return data.get!(Tuple!(T));
}
}
Expand All @@ -161,6 +164,7 @@ private
}
else
{
import std.typecons : Tuple;
return op( data.get!(Tuple!(Args)).expand );
}
}
Expand Down Expand Up @@ -299,6 +303,7 @@ class MailboxFull : Exception
*/
class TidMissingException : Exception
{
import std.exception : basicExceptionCtors;
mixin basicExceptionCtors;
}

Expand Down Expand Up @@ -377,13 +382,17 @@ public:
*/
@property Tid ownerTid()
{
import std.exception : enforce;

enforce!TidMissingException(thisInfo.owner.mbox !is null,
"Error: Thread has no owner thread.");
return thisInfo.owner;
}

@system unittest
{
import std.exception : assertThrown;

static void fun()
{
string res = receiveOnly!string();
Expand Down Expand Up @@ -729,9 +738,14 @@ version (unittest)
private template receiveOnlyRet(T...)
{
static if ( T.length == 1 )
{
alias receiveOnlyRet = T[0];
}
else
{
import std.typecons : Tuple;
alias receiveOnlyRet = Tuple!(T);
}
}

/**
Expand Down Expand Up @@ -770,6 +784,9 @@ in
}
body
{
import std.format : format;
import std.typecons : Tuple;

Tuple!(T) ret;

thisInfo.ident.mbox.get(
Expand Down Expand Up @@ -1034,6 +1051,9 @@ bool register( string name, Tid tid )
*/
bool unregister( string name )
{
import std.algorithm.searching : countUntil;
import std.algorithm.mutation : remove, SwapStrategy;

synchronized( registryLock )
{
if ( auto tid = name in tidByName )
Expand Down Expand Up @@ -1900,6 +1920,8 @@ private
*/
final bool get(T...)( scope T vals )
{
import std.meta : AliasSeq;

static assert( T.length );

static if ( isImplicitlyConvertible!(T[0], Duration) )
Expand Down Expand Up @@ -2237,6 +2259,8 @@ private
{
struct Range
{
import std.exception : enforce;

@property bool empty() const
{
return !m_prev.next;
Expand Down Expand Up @@ -2318,6 +2342,8 @@ private
*/
void removeAt( Range r )
{
import std.exception : enforce;

assert( m_count );
Node* n = r.m_prev;
enforce( n && n.next, "attempting to remove invalid list node" );
Expand Down Expand Up @@ -2448,6 +2474,7 @@ private
version( unittest )
{
import std.stdio;
import std.typecons : tuple, Tuple;

void testfn( Tid tid )
{
Expand Down

0 comments on commit 971da6a

Please sign in to comment.