Skip to content

Commit

Permalink
Auto-convert to D2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Norman committed Feb 16, 2018
1 parent c646488 commit 6b5932f
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 107 deletions.
58 changes: 29 additions & 29 deletions src/dhtproto/client/DhtClient.d
Expand Up @@ -402,7 +402,7 @@ public class DhtClient : IClient
***********************************************************************/

public void opCall ( RequestParams.GetBoolDg output,
public void opCall ( scope RequestParams.GetBoolDg output,
NotifierDg user_notifier )
{
this.reset(output, user_notifier);
Expand All @@ -427,7 +427,7 @@ public class DhtClient : IClient
***********************************************************************/

private void reset ( RequestParams.GetBoolDg output,
private void reset ( scope RequestParams.GetBoolDg output,
NotifierDg user_notifier )
{
this.output = output;
Expand Down Expand Up @@ -685,8 +685,8 @@ public class DhtClient : IClient
***************************************************************************/

public void nodeHandshake ( RequestParams.GetBoolDg output,
RequestNotification.Callback user_notifier )
public void nodeHandshake ( scope RequestParams.GetBoolDg output,
scope RequestNotification.Callback user_notifier )
{
this.node_handshake(output, user_notifier);
}
Expand Down Expand Up @@ -758,8 +758,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public Put put ( Key ) ( cstring channel, Key key, RequestParams.PutValueDg input,
RequestNotification.Callback notifier )
public Put put ( Key ) ( cstring channel, Key key, scope RequestParams.PutValueDg input,
scope RequestNotification.Callback notifier )
{
return *Put(DhtConst.Command.E.Put, notifier).channel(channel).key(key)
.io(input).contextFromKey();
Expand Down Expand Up @@ -798,8 +798,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public Get get ( Key ) ( cstring channel, Key key, RequestParams.GetValueDg output,
RequestNotification.Callback notifier )
public Get get ( Key ) ( cstring channel, Key key, scope RequestParams.GetValueDg output,
scope RequestNotification.Callback notifier )
{
return *Get(DhtConst.Command.E.Get, notifier).channel(channel).key(key)
.io(output).contextFromKey();
Expand Down Expand Up @@ -836,8 +836,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public Exists exists ( Key ) ( cstring channel, Key key, RequestParams.GetBoolDg output,
RequestNotification.Callback notifier )
public Exists exists ( Key ) ( cstring channel, Key key, scope RequestParams.GetBoolDg output,
scope RequestNotification.Callback notifier )
{
return *Exists(DhtConst.Command.E.Exists, notifier).channel(channel)
.key(key).io(output).contextFromKey();
Expand Down Expand Up @@ -869,7 +869,7 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public Remove remove ( Key ) ( cstring channel, Key key, RequestNotification.Callback notifier )
public Remove remove ( Key ) ( cstring channel, Key key, scope RequestNotification.Callback notifier )
{
return *Remove(DhtConst.Command.E.Remove, notifier).channel(channel)
.key(key).contextFromKey();
Expand Down Expand Up @@ -914,8 +914,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetAll getAll ( cstring channel, RequestParams.GetPairDg output,
RequestNotification.Callback notifier )
public GetAll getAll ( cstring channel, scope RequestParams.GetPairDg output,
scope RequestNotification.Callback notifier )
{
return *GetAll(DhtConst.Command.E.GetAll, notifier).channel(channel)
.io(output);
Expand Down Expand Up @@ -959,8 +959,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetAllKeys getAllKeys ( cstring channel, RequestParams.GetValueDg output,
RequestNotification.Callback notifier )
public GetAllKeys getAllKeys ( cstring channel, scope RequestParams.GetValueDg output,
scope RequestNotification.Callback notifier )
{
return *GetAllKeys(DhtConst.Command.E.GetAllKeys, notifier)
.channel(channel).io(output);
Expand Down Expand Up @@ -1003,8 +1003,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public Listen listen ( cstring channel, RequestParams.GetPairDg output,
RequestNotification.Callback notifier )
public Listen listen ( cstring channel, scope RequestParams.GetPairDg output,
scope RequestNotification.Callback notifier )
{
return *Listen(DhtConst.Command.E.Listen, notifier).channel(channel)
.io(output);
Expand Down Expand Up @@ -1046,8 +1046,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetChannels getChannels ( RequestParams.GetNodeValueDg output,
RequestNotification.Callback notifier )
public GetChannels getChannels ( scope RequestParams.GetNodeValueDg output,
scope RequestNotification.Callback notifier )
{
return *GetChannels(DhtConst.Command.E.GetChannels, notifier).io(output);
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetSize getSize ( RequestParams.GetSizeInfoDg output, RequestNotification.Callback notifier )
public GetSize getSize ( scope RequestParams.GetSizeInfoDg output, scope RequestNotification.Callback notifier )
{
return *GetSize(DhtConst.Command.E.GetSize, notifier).io(output);
}
Expand Down Expand Up @@ -1130,7 +1130,7 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetChannelSize getChannelSize ( cstring channel, RequestParams.GetChannelSizeInfoDg output, RequestNotification.Callback notifier )
public GetChannelSize getChannelSize ( cstring channel, scope RequestParams.GetChannelSizeInfoDg output, scope RequestNotification.Callback notifier )
{
return *GetChannelSize(DhtConst.Command.E.GetChannelSize, notifier)
.channel(channel).io(output);
Expand Down Expand Up @@ -1164,7 +1164,7 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public RemoveChannel removeChannel ( cstring channel, RequestNotification.Callback notifier )
public RemoveChannel removeChannel ( cstring channel, scope RequestNotification.Callback notifier )
{
return *RemoveChannel(DhtConst.Command.E.RemoveChannel, notifier)
.channel(channel);
Expand Down Expand Up @@ -1205,8 +1205,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetNumConnections getNumConnections ( RequestParams.GetNumConnectionsDg output,
RequestNotification.Callback notifier )
public GetNumConnections getNumConnections ( scope RequestParams.GetNumConnectionsDg output,
scope RequestNotification.Callback notifier )
{
return *GetNumConnections(DhtConst.Command.E.GetNumConnections, notifier)
.io(output);
Expand Down Expand Up @@ -1249,8 +1249,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetVersion getVersion ( RequestParams.GetNodeValueDg output,
RequestNotification.Callback notifier )
public GetVersion getVersion ( scope RequestParams.GetNodeValueDg output,
scope RequestNotification.Callback notifier )
{
return *GetVersion(DhtConst.Command.E.GetVersion, notifier).io(output);
}
Expand Down Expand Up @@ -1291,8 +1291,8 @@ public class DhtClient : IClient
mixin RequestParamsSetup; // private setup() method, used by assign()
}

public GetResponsibleRange getResponsibleRange ( RequestParams.GetResponsibleRangeDg output,
RequestNotification.Callback notifier )
public GetResponsibleRange getResponsibleRange ( scope RequestParams.GetResponsibleRangeDg output,
scope RequestNotification.Callback notifier )
{
return *GetResponsibleRange(DhtConst.Command.E.GetResponsibleRange,
notifier).io(output);
Expand All @@ -1315,7 +1315,7 @@ public class DhtClient : IClient
***************************************************************************/

override protected void scopeRequestParams (
void delegate ( IRequestParams params ) dg )
scope void delegate ( IRequestParams params ) dg )
{
scope params = new RequestParams;
dg(params);
Expand Down
6 changes: 3 additions & 3 deletions src/dhtproto/client/legacy/DhtConst.d
Expand Up @@ -56,7 +56,7 @@ static:
***************************************************************************/

public const ApiVersion = "20110401";
public enum ApiVersion = "20110401";


/***************************************************************************
Expand All @@ -66,7 +66,7 @@ static:
***************************************************************************/

public const RecordSizeLimit = RecordBatch.DefaultMaxBatchSize;
public enum RecordSizeLimit = RecordBatch.DefaultMaxBatchSize;


/***************************************************************************
Expand Down Expand Up @@ -221,6 +221,6 @@ public struct NodeHashRange

public equals_t opEquals ( NodeHashRange rhs )
{
return this.opCmp(rhs) == 0;
return (&this).opCmp(rhs) == 0;
}
}
4 changes: 2 additions & 2 deletions src/dhtproto/client/legacy/common/NodeRecordBatcher.d
Expand Up @@ -94,10 +94,10 @@ public class NodeRecordBatcher
{
private hash_t[] hashes;

public int opApply ( int delegate ( ref hash_t hash ) dg )
public int opApply ( scope int delegate ( ref hash_t hash ) dg )
{
int r;
foreach ( h; this.hashes )
foreach ( h; (&this).hashes )
{
r = dg(h);
if ( r ) break;
Expand Down
12 changes: 6 additions & 6 deletions src/dhtproto/client/legacy/internal/helper/ChannelMirror.d
Expand Up @@ -91,7 +91,7 @@ abstract public class ChannelMirror ( Dht : DhtClient )
***********************************************************************/

public this ( Dht.RequestNotification.Callback notifier = null )
public this ( scope Dht.RequestNotification.Callback notifier = null )
{
super(this.outer.dht.listen(this.outer.channel_,
&this.outer.listenReceiveRecord, notifier));
Expand Down Expand Up @@ -167,7 +167,7 @@ abstract public class ChannelMirror ( Dht : DhtClient )
***********************************************************************/

public this ( Dht.RequestNotification.Callback notifier = null )
public this ( scope Dht.RequestNotification.Callback notifier = null )
{
super(this.outer.dht.getAll(this.outer.channel_,
&this.outer.getAllReceiveRecord,
Expand Down Expand Up @@ -326,7 +326,7 @@ abstract public class ChannelMirror ( Dht : DhtClient )

public this ( Dht dht, cstring channel,
uint update_time_s, uint retry_time_s,
Dht.RequestNotification.Callback notifier = null )
scope Dht.RequestNotification.Callback notifier = null )
{
this.dht = dht;
this.channel_ = idup(channel);
Expand Down Expand Up @@ -361,7 +361,7 @@ abstract public class ChannelMirror ( Dht : DhtClient )
public this ( Dht dht, cstring channel,
uint update_time_s, uint retry_time_s,
lazy ListenRequest listen, lazy GetAllRequest get_all,
Dht.RequestNotification.Callback notifier = null )
scope Dht.RequestNotification.Callback notifier = null )
{
this.dht = dht;
this.channel_ = idup(channel);
Expand Down Expand Up @@ -621,8 +621,8 @@ unittest
// Dummy concrete channel mirror class
class Mirror : ChannelMirror!(SchedulingDhtClient)
{
const UpdatePeriod = 60; // do a GetAll every 60 seconds
const RetryPeriod = 3; // retry failed requests after 3 seconds
static immutable UpdatePeriod = 60; // do a GetAll every 60 seconds
static immutable RetryPeriod = 3; // retry failed requests after 3 seconds

public this ( SchedulingDhtClient dht, in char[] channel )
{
Expand Down
Expand Up @@ -154,8 +154,8 @@ public class ExtensibleChannelMirror ( Dht : DhtClient, Plugins ... )

public this ( Dht dht, cstring channel,
uint update_time_s, uint retry_time_s,
Dht.RequestNotification.Callback request_notifier,
PluginNotifier plugin_notifier,
scope Dht.RequestNotification.Callback request_notifier,
scope PluginNotifier plugin_notifier,
Plugins plugin_instances )
{
super(dht, channel, update_time_s, retry_time_s, request_notifier);
Expand Down Expand Up @@ -260,7 +260,7 @@ unittest
istring toString ( )
{
return format("[{}, {}, {}]",
this.update_time, this.id, this.count);
(&this).update_time, (&this).id, (&this).count);
}
}

Expand All @@ -277,7 +277,7 @@ unittest
epoll.eventLoop();

// Add some records to the channel being mirrored
const num_records = 10;
static immutable num_records = 10;
for ( hash_t i = 0; i < num_records; i++ )
{
mstring put_dg ( DhtClient.RequestContext c )
Expand Down Expand Up @@ -466,7 +466,7 @@ public class RawRecordDeserializer ( T )
***************************************************************************/

private const bool isVersioned = Version.Info!(T).exists;
private static immutable bool isVersioned = Version.Info!(T).exists;

static if (isVersioned)
{
Expand Down
14 changes: 7 additions & 7 deletions src/dhtproto/client/legacy/internal/helper/RetryHandshake.d
Expand Up @@ -99,8 +99,8 @@ class RetryHandshake
***************************************************************************/

public this ( EpollSelectDispatcher epoll, DhtClient dht,
size_t wait_time, void delegate ( ) handshake_complete_dg = null,
void delegate ( NodeItem ) one_node_handshake_dg = null )
size_t wait_time, scope void delegate ( ) handshake_complete_dg = null,
scope void delegate ( NodeItem ) one_node_handshake_dg = null )
{
this.wait_time = wait_time;

Expand Down Expand Up @@ -257,16 +257,16 @@ unittest
// event loop running.
void main ( )
{
this.epoll = new EpollSelectDispatcher;
this.dht = new DhtClient(this.epoll);
(&this).epoll = new EpollSelectDispatcher;
(&this).dht = new DhtClient((&this).epoll);
// In a real app, you should call `this.dht.addNodes(...);`

// Start the handshake
auto retry_delay_seconds = 3;
new RetryHandshake(this.epoll, this.dht, retry_delay_seconds,
&this.handshake_complete_dg, &this.node_connected_dg);
new RetryHandshake((&this).epoll, (&this).dht, retry_delay_seconds,
&(&this).handshake_complete_dg, &(&this).node_connected_dg);

this.epoll.eventLoop();
(&this).epoll.eventLoop();
}

// Called when an individual node is initially connected.
Expand Down
Expand Up @@ -151,7 +151,7 @@ unittest

equals_t opEquals ( S rhs )
{
return this.x == rhs.x && this.y == rhs.y && this.s == rhs.s;
return (&this).x == rhs.x && (&this).y == rhs.y && (&this).s == rhs.s;
}
}

Expand Down
Expand Up @@ -71,7 +71,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo
***************************************************************************/

private const expected_nodes = 100;
private static immutable expected_nodes = 100;


/***************************************************************************
Expand Down Expand Up @@ -401,7 +401,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo
**************************************************************************/

public int opApply ( int delegate ( ref IDhtNodeConnectionPoolInfo ) dg )
public int opApply ( scope int delegate ( ref IDhtNodeConnectionPoolInfo ) dg )
{
int ret;

Expand Down Expand Up @@ -580,7 +580,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo
***************************************************************************/

private int opApply ( int delegate ( ref DhtNodeConnectionPool ) dg )
private int opApply ( scope int delegate ( ref DhtNodeConnectionPool ) dg )
{
int res;
foreach ( pool; this.nodes.list )
Expand All @@ -602,7 +602,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo
***************************************************************************/

private int opApply ( int delegate ( ref size_t, ref DhtNodeConnectionPool ) dg )
private int opApply ( scope int delegate ( ref size_t, ref DhtNodeConnectionPool ) dg )
{
int res;
size_t i;
Expand Down
Expand Up @@ -122,7 +122,7 @@ public interface IDhtNodeRegistryInfo : INodeRegistryInfo
**************************************************************************/

public int opApply ( int delegate ( ref IDhtNodeConnectionPoolInfo ) dg );
public int opApply ( scope int delegate ( ref IDhtNodeConnectionPoolInfo ) dg );


/***************************************************************************
Expand Down

0 comments on commit 6b5932f

Please sign in to comment.