@@ -59,17 +59,10 @@ const kMask = kSize - 1;
59
59
// but allows much quicker checks.
60
60
61
61
class FixedCircularBuffer {
62
- bottom : number
63
- top : number
64
- list : Array < Task | undefined >
65
- next : FixedCircularBuffer | null
66
-
67
- constructor ( ) {
68
- this . bottom = 0 ;
69
- this . top = 0 ;
70
- this . list = new Array ( kSize ) ;
71
- this . next = null ;
72
- }
62
+ bottom : number = 0
63
+ top : number = 0
64
+ list : Array < Task | undefined > = new Array ( kSize )
65
+ next : FixedCircularBuffer | null = null
73
66
74
67
isEmpty ( ) {
75
68
return this . top === this . bottom ;
@@ -116,7 +109,7 @@ class FixedCircularBuffer {
116
109
export class FixedQueue implements TaskQueue {
117
110
head : FixedCircularBuffer
118
111
tail : FixedCircularBuffer
119
- _size : number = 0
112
+ #size : number = 0
120
113
121
114
constructor ( ) {
122
115
this . head = this . tail = new FixedCircularBuffer ( ) ;
@@ -133,13 +126,13 @@ export class FixedQueue implements TaskQueue {
133
126
this . head = this . head . next = new FixedCircularBuffer ( ) ;
134
127
}
135
128
this . head . push ( data ) ;
136
- this . _size ++ ;
129
+ this . #size ++ ;
137
130
}
138
131
139
132
shift ( ) : Task | null {
140
133
const tail = this . tail ;
141
134
const next = tail . shift ( ) ;
142
- if ( next !== null ) this . _size -- ;
135
+ if ( next !== null ) this . #size -- ;
143
136
if ( tail . isEmpty ( ) && tail . next !== null ) {
144
137
// If there is another queue, it forms the new tail.
145
138
this . tail = tail . next ;
@@ -154,7 +147,7 @@ export class FixedQueue implements TaskQueue {
154
147
while ( true ) {
155
148
if ( buffer . list . includes ( task ) ) {
156
149
buffer . remove ( task ) ;
157
- this . _size -- ;
150
+ this . #size -- ;
158
151
break ;
159
152
}
160
153
if ( buffer . next === null ) break ;
@@ -179,6 +172,6 @@ export class FixedQueue implements TaskQueue {
179
172
}
180
173
181
174
get size ( ) {
182
- return this . _size ;
175
+ return this . #size ;
183
176
}
184
177
} ;
0 commit comments