Skip to content

Commit

Permalink
Merge pull request #165 from pcbro/patch-2
Browse files Browse the repository at this point in the history
Change master/slave to leader/follower in test
  • Loading branch information
jckarter committed Dec 4, 2015
2 parents 872dc69 + 8bda440 commit c2b5546
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions validation-test/stdlib/StringSlicesConcurrentAppend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ extension String {
// different non-shared strings that point to the same shared buffer.

enum ThreadID {
case Master
case Slave
case Leader
case Follower
}

var barrierVar: UnsafeMutablePointer<_stdlib_pthread_barrier_t> = nil
var sharedString: String = ""
var slaveString: String = ""
var followerString: String = ""

func barrier() {
var ret = _stdlib_pthread_barrier_wait(barrierVar)
Expand All @@ -41,7 +41,7 @@ func barrier() {
func sliceConcurrentAppendThread(tid: ThreadID) {
for i in 0..<100 {
barrier()
if tid == .Master {
if tid == .Leader {
// Get a fresh buffer.
sharedString = ""
sharedString.appendContentsOf("abc")
Expand All @@ -57,7 +57,7 @@ func sliceConcurrentAppendThread(tid: ThreadID) {
barrier()

// Append to the private string.
if tid == .Master {
if tid == .Leader {
privateString.appendContentsOf("def")
} else {
privateString.appendContentsOf("ghi")
Expand All @@ -74,14 +74,14 @@ func sliceConcurrentAppendThread(tid: ThreadID) {
expectEqual("abc", sharedString)

// Verify that only one thread took ownership of the buffer.
if tid == .Slave {
slaveString = privateString
if tid == .Follower {
followerString = privateString
}
barrier()
if tid == .Master {
if tid == .Leader {
expectTrue(
(privateString.bufferID == sharedString.bufferID) !=
(slaveString.bufferID == sharedString.bufferID))
(followerString.bufferID == sharedString.bufferID))
}
}
}
Expand All @@ -93,9 +93,9 @@ StringTestSuite.test("SliceConcurrentAppend") {
expectEqual(0, ret)

let (createRet1, tid1) = _stdlib_pthread_create_block(
nil, sliceConcurrentAppendThread, .Master)
nil, sliceConcurrentAppendThread, .Leader)
let (createRet2, tid2) = _stdlib_pthread_create_block(
nil, sliceConcurrentAppendThread, .Slave)
nil, sliceConcurrentAppendThread, .Follower)

expectEqual(0, createRet1)
expectEqual(0, createRet2)
Expand Down

3 comments on commit c2b5546

@MikeThomas1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. The naming is now PC compliant.

PC NIU.

@NinoScript
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this go against what the API Design Guidelines say about embracing precedent?

API Design Guidelines / Naming / Use Terminology Well / Embrace precedent

@pcperini
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NinoScript the guideline doesn't say "keep everything the same forever," it says "don't over-optimize for beginners." This PR has nothing to do with optimizing for beginners and instead is steering the existing culture toward suitability for a more diverse group of contributors.

I might propose an amendment to the guideline to clarify that distinction. Perhaps:

Don’t optimize terms for the total beginner at the expense of conformance to internal consistency.

The change from "existing culture" to "internal consistency" allows for the culture to be defined as more fluid.

Please sign in to comment.