diff --git a/integrationtest/channelserializer/main.d b/integrationtest/channelserializer/main.d index 30577f99..e6691918 100644 --- a/integrationtest/channelserializer/main.d +++ b/integrationtest/channelserializer/main.d @@ -85,7 +85,7 @@ int main ( istring[] args ) { auto ser = new ChannelSerializer!(S)("failed_channel"); - void dumpRecord ( void delegate ( hash_t, ref Contiguous!(S) ) record_dg ) + void dumpRecord ( scope void delegate ( hash_t, ref Contiguous!(S) ) record_dg ) { throw new Exception("File write error"); } diff --git a/src/dhtproto/client/DhtClient.d b/src/dhtproto/client/DhtClient.d index 9693aece..1bdcde39 100644 --- a/src/dhtproto/client/DhtClient.d +++ b/src/dhtproto/client/DhtClient.d @@ -403,7 +403,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); @@ -428,7 +428,7 @@ public class DhtClient : IClient ***********************************************************************/ - private void reset ( RequestParams.GetBoolDg output, + private void reset ( scope RequestParams.GetBoolDg output, NotifierDg user_notifier ) { this.output = output; @@ -686,8 +686,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); } @@ -759,8 +759,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(); @@ -799,8 +799,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(); @@ -837,8 +837,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(); @@ -870,7 +870,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(); @@ -915,8 +915,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); @@ -960,8 +960,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); @@ -1004,8 +1004,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); @@ -1047,8 +1047,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); } @@ -1088,7 +1088,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); } @@ -1131,7 +1131,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); @@ -1165,7 +1165,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); @@ -1206,8 +1206,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); @@ -1250,8 +1250,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); } @@ -1292,8 +1292,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); @@ -1316,7 +1316,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); diff --git a/src/dhtproto/client/helper/ChannelSerializer.d b/src/dhtproto/client/helper/ChannelSerializer.d index 3b6fd933..eaa21157 100644 --- a/src/dhtproto/client/helper/ChannelSerializer.d +++ b/src/dhtproto/client/helper/ChannelSerializer.d @@ -97,7 +97,7 @@ public class ChannelSerializer ( S ) public this ( istring path ) { - const buffer_size = 64 * 1024; + static immutable buffer_size = 64 * 1024; this.path = path; this.buffered_output = new BufferedOutput(null, buffer_size); @@ -124,7 +124,7 @@ public class ChannelSerializer ( S ) public bool dump ( Contiguous!(S)[hash_t] aa, bool block = false ) { - void dumpAA ( void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) + void dumpAA ( scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) { foreach ( k, v; aa) dump_record(k, v); @@ -148,7 +148,7 @@ public class ChannelSerializer ( S ) public bool dump ( Map!(Contiguous!(S), hash_t) map, bool block = false ) { - void dumpMap ( void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) + void dumpMap ( scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) { foreach ( k, v; map) dump_record(k, v); @@ -171,7 +171,7 @@ public class ChannelSerializer ( S ) ***************************************************************************/ - public bool dump ( DumpRecordDg record_dump_dg, bool block = false ) + public bool dump ( scope DumpRecordDg record_dump_dg, bool block = false ) { this.record_dump_dg = record_dump_dg; return this.fork.call(block); @@ -222,7 +222,7 @@ public class ChannelSerializer ( S ) ***************************************************************************/ - public void load ( LoadRecordDg record_load_dg ) + public void load ( scope LoadRecordDg record_load_dg ) { size_t num_records; scope file = new File(this.path, File.ReadExisting); @@ -346,7 +346,7 @@ unittest void dumpChannelFromContainer ( ) { void containerIterator ( - void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) + scope void delegate ( hash_t, ref Contiguous!(S) ) dump_record ) { Contiguous!(S) v; diff --git a/src/dhtproto/client/legacy/DhtConst.d b/src/dhtproto/client/legacy/DhtConst.d index c7f08754..50104dd6 100644 --- a/src/dhtproto/client/legacy/DhtConst.d +++ b/src/dhtproto/client/legacy/DhtConst.d @@ -56,7 +56,7 @@ static: ***************************************************************************/ - public const ApiVersion = "20110401"; + public enum ApiVersion = "20110401"; /*************************************************************************** @@ -66,7 +66,7 @@ static: ***************************************************************************/ - public const RecordSizeLimit = RecordBatch.DefaultMaxBatchSize; + public enum RecordSizeLimit = RecordBatch.DefaultMaxBatchSize; /*************************************************************************** @@ -221,6 +221,6 @@ public struct NodeHashRange public equals_t opEquals ( NodeHashRange rhs ) { - return this.opCmp(rhs) == 0; + return (&this).opCmp(rhs) == 0; } } diff --git a/src/dhtproto/client/legacy/common/NodeRecordBatcher.d b/src/dhtproto/client/legacy/common/NodeRecordBatcher.d index b909d241..03172346 100644 --- a/src/dhtproto/client/legacy/common/NodeRecordBatcher.d +++ b/src/dhtproto/client/legacy/common/NodeRecordBatcher.d @@ -95,10 +95,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; diff --git a/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d b/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d index ca8cfa95..5eb6e01d 100644 --- a/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d +++ b/src/dhtproto/client/legacy/internal/helper/ChannelMirror.d @@ -79,7 +79,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***********************************************************************/ - 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)); @@ -158,7 +158,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***********************************************************************/ - 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, @@ -273,7 +273,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) 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 ) { super(dht, channel, update_time_s, retry_time_s); @@ -305,7 +305,7 @@ abstract public class ChannelMirror ( Dht : DhtClient ) : MirrorBase!(Dht) 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 ) { super(dht, channel, update_time_s, retry_time_s); @@ -437,8 +437,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 ) { diff --git a/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d b/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d index d03c920a..b3271d78 100644 --- a/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d +++ b/src/dhtproto/client/legacy/internal/helper/ExtensibleChannelMirror.d @@ -158,8 +158,8 @@ public class ExtensibleMirror 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); @@ -312,7 +312,7 @@ unittest istring toString ( ) { return format("[{}, {}, {}]", - this.update_time, this.id, this.count); + (&this).update_time, (&this).id, (&this).count); } } @@ -331,7 +331,7 @@ unittest enforce(handshake_ok); // 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 ) @@ -520,7 +520,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) { diff --git a/src/dhtproto/client/legacy/internal/helper/Mirror.d b/src/dhtproto/client/legacy/internal/helper/Mirror.d index 354b256d..48dbb486 100644 --- a/src/dhtproto/client/legacy/internal/helper/Mirror.d +++ b/src/dhtproto/client/legacy/internal/helper/Mirror.d @@ -391,7 +391,7 @@ abstract public class Mirror ( Dht : DhtClient ) : MirrorBase!(Dht) ***************************************************************************/ public this ( Dht dht, cstring channel, uint update_time_s, - uint retry_time_s, Dht.RequestNotification.Callback notifier = null ) + uint retry_time_s, scope Dht.RequestNotification.Callback notifier = null ) { super(dht, channel, update_time_s, retry_time_s); this.user_notifier = notifier; @@ -568,8 +568,8 @@ unittest // Dummy concrete channel mirror class class ExampleMirror : Mirror!(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, cstring channel ) { diff --git a/src/dhtproto/client/legacy/internal/helper/NodeAvailability.d b/src/dhtproto/client/legacy/internal/helper/NodeAvailability.d index 037a2c60..cd757127 100644 --- a/src/dhtproto/client/legacy/internal/helper/NodeAvailability.d +++ b/src/dhtproto/client/legacy/internal/helper/NodeAvailability.d @@ -47,15 +47,15 @@ public struct NodeAvailabilty public void error ( NodeItem node ) { - if ( auto tracker = node.toHash() in this.error_trackers ) + if ( auto tracker = node.toHash() in (&this).error_trackers ) { tracker.error(); } else { - auto tracker = NodeErrorTracker(this); + auto tracker = NodeErrorTracker((&this)); tracker.error(); - this.error_trackers[node.toHash()] = tracker; + (&this).error_trackers[node.toHash()] = tracker; } } @@ -104,7 +104,7 @@ public struct NodeAvailabilty public bool available ( NodeItem node ) { - if ( auto tracker = node.toHash() in this.error_trackers ) + if ( auto tracker = node.toHash() in (&this).error_trackers ) return tracker.available(); else return true; @@ -128,7 +128,7 @@ public struct NodeAvailabilty public void error ( ) { - this.last_error_timestamp = time(); + (&this).last_error_timestamp = time(); } /*********************************************************************** @@ -144,8 +144,8 @@ public struct NodeAvailabilty public bool available ( ) { - auto diff = time() - this.last_error_timestamp; - return diff >= this.outer.retry_delay_s; + auto diff = time() - (&this).last_error_timestamp; + return diff >= (&this).outer.retry_delay_s; } /*********************************************************************** diff --git a/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d b/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d index 1da26d06..5441bf8d 100644 --- a/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d +++ b/src/dhtproto/client/legacy/internal/helper/RetryHandshake.d @@ -76,8 +76,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; @@ -244,18 +244,18 @@ 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; // Store the reference to the RetryHandshake // object so it doesn't get garbage collected. - auto handshake = new RetryHandshake(this.epoll, this.dht, retry_delay_seconds, - &this.handshake_complete_dg, &this.node_connected_dg); + auto handshake = 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. diff --git a/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d b/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d index 43c08b08..56c47660 100644 --- a/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d +++ b/src/dhtproto/client/legacy/internal/helper/mirror/ContiguousRecordCache.d @@ -152,7 +152,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; } } diff --git a/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d b/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d index 2aa083a1..a40ed201 100644 --- a/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d +++ b/src/dhtproto/client/legacy/internal/registry/DhtNodeRegistry.d @@ -72,7 +72,7 @@ public class DhtNodeRegistry : NodeRegistry, IDhtNodeRegistryInfo ***************************************************************************/ - private const expected_nodes = 100; + private static immutable expected_nodes = 100; /*************************************************************************** @@ -404,7 +404,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; @@ -583,7 +583,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 ) @@ -605,7 +605,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; diff --git a/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d b/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d index 5a6e0fea..ecbbfd44 100644 --- a/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d +++ b/src/dhtproto/client/legacy/internal/registry/model/IDhtNodeRegistryInfo.d @@ -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 ); /*************************************************************************** diff --git a/src/dhtproto/client/legacy/internal/request/params/RequestParams.d b/src/dhtproto/client/legacy/internal/request/params/RequestParams.d index dd8553c8..2b54e650 100644 --- a/src/dhtproto/client/legacy/internal/request/params/RequestParams.d +++ b/src/dhtproto/client/legacy/internal/request/params/RequestParams.d @@ -173,7 +173,7 @@ public class RequestParams : IChannelRequestParams ***************************************************************************/ - override protected void notify_ ( void delegate ( IRequestNotification ) info_dg ) + override protected void notify_ ( scope void delegate ( IRequestNotification ) info_dg ) { scope info = new RequestNotification(cast(DhtConst.Command.E)this.command, this.context); diff --git a/src/dhttest/DhtClient.d b/src/dhttest/DhtClient.d index f68a5d59..f5debcef 100644 --- a/src/dhttest/DhtClient.d +++ b/src/dhttest/DhtClient.d @@ -184,7 +184,7 @@ class DhtClient { this.log = Log.lookup("dhttest"); - const max_connections = 2; + static immutable max_connections = 2; this.swarm_client = new SwarmClient(theScheduler.epoll, max_connections); } @@ -550,7 +550,7 @@ class DhtClient public Listener startListen ( cstring channel ) { - const hash_t key = 0xDEAD; + static immutable hash_t key = 0xDEAD; auto listener = new Listener; diff --git a/src/dhttest/cases/Basic.d b/src/dhttest/cases/Basic.d index a43c9470..107ffdbf 100644 --- a/src/dhttest/cases/Basic.d +++ b/src/dhttest/cases/Basic.d @@ -23,7 +23,7 @@ import ocean.transition; import dhttest.DhtTestCase; -const PRIORITY = 100; +static immutable PRIORITY = 100; /******************************************************************************* diff --git a/src/dhttest/cases/BasicListen.d b/src/dhttest/cases/BasicListen.d index 3ef6c6ef..efadfcf0 100644 --- a/src/dhttest/cases/BasicListen.d +++ b/src/dhttest/cases/BasicListen.d @@ -26,7 +26,7 @@ import ocean.core.Test; import ocean.io.select.fiber.SelectFiber; import ocean.io.select.client.FiberTimerEvent; -const PRIORITY = 90; +static immutable PRIORITY = 90; /******************************************************************************* @@ -51,7 +51,7 @@ class ListenRemovedChannel : DhtTestCase override public void run ( ) { auto listener = this.dht.startListen(this.test_channel); - const key = 0; + static immutable key = 0; this.dht.put(this.test_channel, key, "whatever"[]); listener.waitNextEvent(); test(!listener.finished); @@ -87,7 +87,7 @@ class ListenTrigger : DhtTestCase { auto listener = this.dht.startListen(this.test_channel); - const key = 5; + static immutable key = 5; this.dht.put(this.test_channel, key, "value"[]); listener.waitNextEvent(); test!("==")(listener.data.length, 1); diff --git a/src/dhttest/util/LocalStore.d b/src/dhttest/util/LocalStore.d index 90da499a..acad90e4 100644 --- a/src/dhttest/util/LocalStore.d +++ b/src/dhttest/util/LocalStore.d @@ -54,7 +54,7 @@ struct LocalStore public void put ( hash_t key, cstring val ) { - this.data[key] = val.dup; + (&this).data[key] = val.dup; } /*************************************************************************** @@ -68,7 +68,7 @@ struct LocalStore public void remove ( hash_t key ) { - this.data.remove(key); + (&this).data.remove(key); } } @@ -107,14 +107,14 @@ public struct LegacyVerifier public void verifyAgainstDht ( ref LocalStore local, DhtClient dht, cstring channel ) { - this.local = &local; - - this.verifyGetChannelSize(dht, channel); - this.verifyGetAll(dht, channel); - this.verifyGetAllFilter(dht, channel); - this.verifyGetAllKeys(dht, channel); - this.verifyExists(dht, channel); - this.verifyGet(dht, channel); + (&this).local = &local; + + (&this).verifyGetChannelSize(dht, channel); + (&this).verifyGetAll(dht, channel); + (&this).verifyGetAllFilter(dht, channel); + (&this).verifyGetAllKeys(dht, channel); + (&this).verifyExists(dht, channel); + (&this).verifyGet(dht, channel); } /*************************************************************************** @@ -136,8 +136,8 @@ public struct LegacyVerifier ulong records, bytes; dht.getChannelSize(channel, records, bytes); log.trace("\tVerifying channel with GetChannelSize: local:{}, remote:{}", - this.local.data.length, records); - test!("==")(this.local.data.length, records); + (&this).local.data.length, records); + test!("==")((&this).local.data.length, records); } /*************************************************************************** @@ -158,13 +158,13 @@ public struct LegacyVerifier { auto remote = dht.getAll(channel); log.trace("\tVerifying channel with GetAll: local:{}, remote:{}", - this.local.data.length, remote.length); - test!("==")(this.local.data.length, remote.length); + (&this).local.data.length, remote.length); + test!("==")((&this).local.data.length, remote.length); foreach ( k, v; remote ) { - test!("in")(k, this.local.data); - test!("==")(v, this.local.data[k]); + test!("in")(k, (&this).local.data); + test!("==")(v, (&this).local.data[k]); } } @@ -186,10 +186,10 @@ public struct LegacyVerifier private void verifyGetAllFilter ( DhtClient dht, cstring channel ) { - const filter = "0"; + enum filter = "0"; hash_t[] local; - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { if ( v.contains(filter) ) local ~= k; @@ -203,7 +203,7 @@ public struct LegacyVerifier foreach ( k, v; remote ) { test(local.contains(k)); - test!("==")(v, this.local.data[k]); + test!("==")(v, (&this).local.data[k]); } } @@ -225,12 +225,12 @@ public struct LegacyVerifier { auto remote = dht.getAllKeys(channel); log.trace("\tVerifying channel with GetAllKeys: local:{}, remote:{}", - this.local.data.length, remote.length); - test!("==")(this.local.data.length, remote.length); + (&this).local.data.length, remote.length); + test!("==")((&this).local.data.length, remote.length); foreach ( k; remote ) { - test!("in")(k, this.local.data); + test!("in")(k, (&this).local.data); } } @@ -251,7 +251,7 @@ public struct LegacyVerifier private void verifyExists ( DhtClient dht, cstring channel ) { log.trace("\tVerifying channel with Exists"); - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { auto exists = dht.exists(channel, k); test(exists); @@ -275,7 +275,7 @@ public struct LegacyVerifier private void verifyGet ( DhtClient dht, cstring channel ) { log.trace("\tVerifying channel with Get"); - foreach ( k, v; this.local.data ) + foreach ( k, v; (&this).local.data ) { auto remote_v = dht.get(channel, k); test!("==")(remote_v, v); diff --git a/src/dummydhtapp/main.d b/src/dummydhtapp/main.d index c9f9856a..c2824a65 100644 --- a/src/dummydhtapp/main.d +++ b/src/dummydhtapp/main.d @@ -108,13 +108,13 @@ void main ( istring[] args ) fiber = new SelectFiber(epoll, &handshakeAndRegister, 256 * 1024); event = new FiberSelectEvent(fiber); - void ping_handler ( cstring args, void delegate ( cstring + void ping_handler ( cstring args, scope void delegate ( cstring response ) send_response ) { send_response("pong " ~ args); } - void reset_handler ( cstring args, void delegate ( cstring + void reset_handler ( cstring args, scope void delegate ( cstring response ) send_response ) { send_response("ACK"); diff --git a/src/fakedht/ConnectionHandler.d b/src/fakedht/ConnectionHandler.d index e44773a1..44d9cccd 100644 --- a/src/fakedht/ConnectionHandler.d +++ b/src/fakedht/ConnectionHandler.d @@ -223,7 +223,7 @@ public class DhtConnectionHandler : ***************************************************************************/ - public this (void delegate(IConnectionHandler) finalize_dg, + public this (scope void delegate(IConnectionHandler) finalize_dg, ConnectionSetupParams setup ) { super(finalize_dg, setup); diff --git a/src/fakedht/DhtNode.d b/src/fakedht/DhtNode.d index 436e8bc8..c1a19642 100644 --- a/src/fakedht/DhtNode.d +++ b/src/fakedht/DhtNode.d @@ -83,7 +83,7 @@ public class DhtNode public this ( DhtConst.NodeItem node_item, EpollSelectDispatcher epoll ) { - const backlog = 20; + static immutable backlog = 20; auto params = new ConnectionSetupParams; params.epoll = epoll; diff --git a/src/fakedht/Storage.d b/src/fakedht/Storage.d index c8f92a71..4fd3f2f0 100644 --- a/src/fakedht/Storage.d +++ b/src/fakedht/Storage.d @@ -72,7 +72,7 @@ struct DHT public Channel get (cstring channel_name) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; if (channel is null) return null; return *channel; @@ -93,7 +93,7 @@ struct DHT public Channel getVerify ( cstring channel_name ) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; enforce!(MissingChannelException)(channel !is null, idup(channel_name)); return *channel; } @@ -112,11 +112,11 @@ struct DHT public Channel getCreate (cstring channel_name) { - auto channel = channel_name in this.channels; + auto channel = channel_name in (&this).channels; if (channel is null) { - this.channels[idup(channel_name)] = new Channel; - channel = channel_name in this.channels; + (&this).channels[idup(channel_name)] = new Channel; + channel = channel_name in (&this).channels; } return *channel; } @@ -132,11 +132,11 @@ struct DHT public void remove (cstring channel_name) { - auto channel = this.get(channel_name); + auto channel = (&this).get(channel_name); if (channel !is null) { channel.listeners.trigger(DhtListener.Code.Finish, ""); - this.channels.remove(idup(channel_name)); + (&this).channels.remove(idup(channel_name)); } } @@ -148,10 +148,10 @@ struct DHT public void clear ( ) { - auto names = this.channels.keys; + auto names = (&this).channels.keys; foreach (name; names) { - auto channel = this.getVerify(name); + auto channel = (&this).getVerify(name); channel.data = null; } } @@ -167,7 +167,7 @@ struct DHT public void dropAllListeners ( ) { - foreach (channel; this.channels) + foreach (channel; (&this).channels) { channel.listeners = channel.new Listeners; } @@ -184,7 +184,7 @@ struct DHT { istring[] result; - foreach (key, value; this.channels) + foreach (key, value; (&this).channels) result ~= key; return result; diff --git a/src/turtle/env/Dht.d b/src/turtle/env/Dht.d index c062fc9d..17a3de60 100644 --- a/src/turtle/env/Dht.d +++ b/src/turtle/env/Dht.d @@ -137,7 +137,7 @@ public class Dht : Node!(DhtNode, "dht") unittest { struct NotVersioned { int x; } - struct Versioned { const StructVersion = 0; int x; } + struct Versioned { enum StructVersion = 0; int x; } // ensures compilation void stub ( ) @@ -350,7 +350,7 @@ public class Dht : Node!(DhtNode, "dht") ***************************************************************************/ public void expectRecordCondition ( cstring channel, hash_t key, - bool delegate ( in void[] record ) dg, + scope bool delegate ( in void[] record ) dg, double timeout = 1.0, double check_interval = 0.05 ) { char[Hash.HashDigits] str_key; @@ -438,7 +438,7 @@ public class Dht : Node!(DhtNode, "dht") ***************************************************************************/ private void waitForCondition ( double timeout, double check_interval, - bool delegate ( ) condition, lazy istring err_msg ) + scope bool delegate ( ) condition, lazy istring err_msg ) { auto total_wait = 0.0; @@ -671,7 +671,7 @@ unittest { struct Something { - const StructVersion = 1; + enum StructVersion = 1; int a, b; }