Skip to content

Commit

Permalink
Renamed exclusive to gcExclusive
Browse files Browse the repository at this point in the history
  • Loading branch information
atilaneves committed Jun 14, 2018
1 parent a84c55a commit 1017415
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions examples/example.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ void main() @safe {
import std.stdio: writeln;
import std.concurrency: spawn, send, receiveOnly, thisTid;

auto s = exclusive!int(42);
auto s = gcExclusive!int(42);

{
auto i = s.lock();
Expand Down Expand Up @@ -40,7 +40,7 @@ void func(Tid tid) @trusted { // Both receive and send are @system
import std.concurrency: receive, send;

receive(
// ref shared(Exclusive!int) didn't work
// ref shared(GcExclusive!int) didn't work
(shared(Exclusive!int)* m) {
auto i = m.lock;
*i = ++*i;
Expand Down
4 changes: 2 additions & 2 deletions source/fearless/sharing.d
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module fearless.sharing;
Allocated on the GC to make sure its lifetime is infinite and therefore
safe to pass to other threads.
*/
auto exclusive(T, A...)(auto ref A args) {
auto gcExclusive(T, A...)(auto ref A args) {
return new shared Exclusive!T(args);
}

Expand All @@ -20,7 +20,7 @@ auto exclusive(T, A...)(auto ref A args) {
This function sets the passed-in payload to payload.init to make sure
that no references to it can be unsafely used.
*/
auto exclusive(T)(ref T payload) {
auto gcExclusive(T)(ref T payload) {
return new shared Exclusive!T(payload);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ut/concurrency.d
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private void threadFunc(Tid tid) {
@("send works")
@safe unittest {
auto tid = spawn(&threadFunc, thisTid);
auto s = exclusive!int(42);
auto s = gcExclusive!int(42);
tid.send(s);
tid.send(Stop());
receiveOnly!Ended;
Expand All @@ -42,7 +42,7 @@ private void threadFunc(Tid tid) {
@("send fails when the mutex is already locked")
@safe unittest {
auto tid = spawn(&threadFunc, thisTid);
auto s = exclusive!int(42);
auto s = gcExclusive!int(42);
{
auto xs = s.lock;
tid.send(s).shouldThrowWithMessage(
Expand Down
6 changes: 3 additions & 3 deletions tests/ut/exclusive.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import unit_threaded;

@("GC exclusive int")
@safe unittest {
auto e = exclusive!int(42);
auto e = gcExclusive!int(42);
}

@("GC exclusive int moved payload")
@safe unittest {

int i = 42;
auto e = exclusive(i);
auto e = gcExclusive(i);

// should be reset to T.init
i.should == 0;
Expand All @@ -29,7 +29,7 @@ import unit_threaded;
@safe unittest {

auto ints = [1, 2, 3, 4];
auto e = exclusive(ints);
auto e = gcExclusive(ints);

// should be reset to T.init
ints.shouldBeEmpty;
Expand Down

0 comments on commit 1017415

Please sign in to comment.