Skip to content

Commit

Permalink
Merge tag 'v5.1.4' into v5.2.x
Browse files Browse the repository at this point in the history
v5.1.4
  • Loading branch information
ben-palmer-sociomantic committed Oct 15, 2019
2 parents 4db5013 + 19bd05b commit aeb8288
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 10 deletions.
11 changes: 11 additions & 0 deletions relnotes/lazy_verify.bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### `verify` now lazily allocates on `throw`, not on call

`ocean.core.Verify`

`verify` used to lazily initialize a `static` exception on the first call.
However, this means that `testNoAlloc(verify(true))` could randomly fail,
depending on the order unittests are executed,
and this transitively affected all users of `verify` (that is, everything).
`verify` will now lazily allocates only on `throw`,
so `testNoAlloc(verify(true))` will always pass,
but `testNoAlloc(verify(false))` could still potentially fail.
8 changes: 8 additions & 0 deletions relnotes/suspendable-throttler-count-opsubassign.bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### Fix `-=` operator implementation in SuspendableThrottlerCount

`ocean.io.model.SuspendableThrottlerCount`

The `-=` operator overload (D1 `opSubAssign`) was inexplicably aliased
to the `add` method rather than the correct `remove`. This probably
means that no one was ever actually using the operator overload, but it
seems a good idea to fix it in any case.
6 changes: 6 additions & 0 deletions relnotes/undeprecate_fieldIdentifier.bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
### Template `Identifier.fieldIdentifier` is no longer deprecated

`ocean.meta.codegen.Identifier.fieldIdentifier`

This template was erroneously marked as deprecated in ocean v5.0.0, but
it is still required. Using it will no longer generate a deprecation warning.
2 changes: 1 addition & 1 deletion src/ocean/core/Traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public M* GetField ( size_t i, M, T ) ( T* t )
*******************************************************************************/

deprecated("Use ocean.meta.codegen.Identifier.identifier!(T.tupleof[i])")
deprecated("Use ocean.meta.codegen.Identifier.fieldIdentifier!(T, i)")
public template FieldName ( size_t i, T )
{
static if ( !isCompoundType!(T) )
Expand Down
6 changes: 3 additions & 3 deletions src/ocean/core/Verify.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public void verify ( bool ok, lazy istring msg = "",
{
static SanityException exc;

if (exc is null)
exc = new SanityException("");

if (!ok)
{
if (exc is null)
exc = new SanityException("");

exc.file = file;
exc.line = line;
exc.msg = msg;
Expand Down
2 changes: 1 addition & 1 deletion src/ocean/io/device/DirectIO.d
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public class BufferedDirectReadFile: InputStream
***************************************************************************/

static private class DirectReadFile : File
static protected class DirectReadFile : File
{
override public void open (cstring path, Style style = this.ReadExisting)
{
Expand Down
48 changes: 47 additions & 1 deletion src/ocean/io/model/SuspendableThrottlerCount.d
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public class SuspendableThrottlerCount : ISuspendableThrottlerCount
super.throttledResume();
}

public alias add opSubAssign;
public alias remove opSubAssign;


/***************************************************************************
Expand All @@ -176,6 +176,52 @@ public class SuspendableThrottlerCount : ISuspendableThrottlerCount
}
}

unittest
{
import ocean.core.Test : test;

// Helper class to allow us to test operator overloads
// without touching other parts of the class logic
static class OpsTest : SuspendableThrottlerCount
{
this ()
{
size_t suspend_point = 8;
size_t resume_point = 3;
super(suspend_point, resume_point);
}

override void inc () { this.count++; }
override void dec () { this.count--; }

override void add (size_t n) { this.count += n; }
override void remove (size_t n) { this.count -= n; }
}

scope ops_test = new OpsTest;
test!"=="(ops_test.length, 0);

ops_test++;
test!"=="(ops_test.length, 1);
test(!ops_test.suspend);
test(ops_test.resume);

ops_test += 7;
test!"=="(ops_test.length, 8);
test(ops_test.suspend);
test(!ops_test.resume);

ops_test--;
test!"=="(ops_test.length, 7);
test(!ops_test.suspend);
test(!ops_test.resume);

ops_test -= 4;
test!"=="(ops_test.length, 3);
test(!ops_test.suspend);
test(ops_test.resume);
}


/*******************************************************************************
Expand Down
5 changes: 2 additions & 3 deletions src/ocean/meta/codegen/Identifier.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ unittest
Template to get the name of the ith member of a struct / class.
Used over plain `identifier` when iterating over aggregate fields with
`.tupleof` as D1 compiler refuses to pass such field as template alias
`.tupleof` as compiler refuses to pass such field as template alias
parameter.
Params:
Expand All @@ -85,13 +85,12 @@ unittest
*******************************************************************************/

deprecated("Use ocean.meta.codegen.identifier!(T.tupleof[i])")
public template fieldIdentifier ( T, size_t i )
{
enum fieldIdentifier = identifier!(T.tupleof[i]);
}

deprecated unittest
unittest
{
static struct TestStruct
{
Expand Down
4 changes: 3 additions & 1 deletion src/ocean/util/app/CliApp.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ import ocean.transition;

abstract class CliApp : Application, IArgumentsExtExtension
{
import ocean.text.Arguments : Arguments;
static import ocean.text.Arguments;
public alias ocean.text.Arguments.Arguments Arguments;

import ocean.util.app.ext.ArgumentsExt;
import ocean.util.app.ext.VersionArgsExt;
import ocean.util.app.ext.TaskExt;
Expand Down

0 comments on commit aeb8288

Please sign in to comment.