@@ -25,13 +25,13 @@ extension String {
25
25
// different non-shared strings that point to the same shared buffer.
26
26
27
27
enum ThreadID {
28
- case Leader
29
- case Follower
28
+ case Primary
29
+ case Replica
30
30
}
31
31
32
32
var barrierVar : UnsafeMutablePointer < _stdlib_pthread_barrier_t > = nil
33
33
var sharedString : String = " "
34
- var followerString : String = " "
34
+ var replicaString : String = " "
35
35
36
36
func barrier( ) {
37
37
var ret = _stdlib_pthread_barrier_wait ( barrierVar)
@@ -41,7 +41,7 @@ func barrier() {
41
41
func sliceConcurrentAppendThread( tid: ThreadID ) {
42
42
for i in 0 ..< 100 {
43
43
barrier ( )
44
- if tid == . Leader {
44
+ if tid == . Primary {
45
45
// Get a fresh buffer.
46
46
sharedString = " "
47
47
sharedString. appendContentsOf ( " abc " )
@@ -57,7 +57,7 @@ func sliceConcurrentAppendThread(tid: ThreadID) {
57
57
barrier ( )
58
58
59
59
// Append to the private string.
60
- if tid == . Leader {
60
+ if tid == . Primary {
61
61
privateString. appendContentsOf ( " def " )
62
62
} else {
63
63
privateString. appendContentsOf ( " ghi " )
@@ -66,22 +66,22 @@ func sliceConcurrentAppendThread(tid: ThreadID) {
66
66
barrier ( )
67
67
68
68
// Verify that contents look good.
69
- if tid == . Leader {
69
+ if tid == . Primary {
70
70
expectEqual ( " abcdef " , privateString)
71
71
} else {
72
72
expectEqual ( " abcghi " , privateString)
73
73
}
74
74
expectEqual ( " abc " , sharedString)
75
75
76
76
// Verify that only one thread took ownership of the buffer.
77
- if tid == . Follower {
78
- followerString = privateString
77
+ if tid == . Replica {
78
+ replicaString = privateString
79
79
}
80
80
barrier ( )
81
- if tid == . Leader {
81
+ if tid == . Primary {
82
82
expectTrue (
83
83
( privateString. bufferID == sharedString. bufferID) !=
84
- ( followerString . bufferID == sharedString. bufferID) )
84
+ ( replicaString . bufferID == sharedString. bufferID) )
85
85
}
86
86
}
87
87
}
@@ -93,9 +93,9 @@ StringTestSuite.test("SliceConcurrentAppend") {
93
93
expectEqual ( 0 , ret)
94
94
95
95
let ( createRet1, tid1) = _stdlib_pthread_create_block (
96
- nil , sliceConcurrentAppendThread, . Leader )
96
+ nil , sliceConcurrentAppendThread, . Primary )
97
97
let ( createRet2, tid2) = _stdlib_pthread_create_block (
98
- nil , sliceConcurrentAppendThread, . Follower )
98
+ nil , sliceConcurrentAppendThread, . Replica )
99
99
100
100
expectEqual ( 0 , createRet1)
101
101
expectEqual ( 0 , createRet2)
0 commit comments