A master ServiceScope.
import std.format : format; // Basic test to make sure the "in use" mask works properly. auto provider = new ServiceProvider(null); ServiceScope[3] scopes; foreach(i; 0..scopes.length) { scopes[i] = provider.createScope(); assert(scopes[i]._index == i + 1, format("%s", scopes[i]._index)); } provider.destroyScope(scopes[1]); // Index 2 assert(scopes[1]._index == 0); assert(scopes[1]._provider is null); assert(provider._scopeInUseMasks[0] == 0b1011); scopes[1] = provider.createScope(); assert(scopes[1]._index == 2); assert(provider._scopeInUseMasks[0] == 0b1111);
Creates a new scope.
Performance: For creating a scope, most of the performance cost is only made during the very first creation of a scope of a specific index. e.g. If you create scope[index=1], destroy it, then make another scope[index=1], the second scope should be made faster.
The speed difference is likely negligable either way though.
Most of the performance costs of making a scope will come from the creation of scoped services for each new scope, but those are only performed lazily anyway.