effect 3.10.15 → 3.10.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,7 +85,7 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
85
85
  private messagesChunk = Chunk.empty<A>()
86
86
  constructor(
87
87
  readonly scheduler: Scheduler,
88
- readonly capacity: number,
88
+ private capacity: number,
89
89
  readonly strategy: "suspend" | "dropping" | "sliding"
90
90
  ) {
91
91
  super()
@@ -100,6 +100,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
100
100
  case "dropping":
101
101
  return exitFalse
102
102
  case "suspend":
103
+ if (this.capacity <= 0 && this.state.takers.size > 0) {
104
+ this.messages.push(message)
105
+ this.releaseTaker()
106
+ return exitTrue
107
+ }
103
108
  return this.offerRemainingSingle(message)
104
109
  case "sliding":
105
110
  this.unsafeTake()
@@ -120,6 +125,10 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
120
125
  this.unsafeTake()
121
126
  this.messages.push(message)
122
127
  return true
128
+ } else if (this.capacity <= 0 && this.state.takers.size > 0) {
129
+ this.messages.push(message)
130
+ this.releaseTaker()
131
+ return true
123
132
  }
124
133
  return false
125
134
  }
@@ -164,7 +173,9 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
164
173
  this.scheduleReleaseTaker()
165
174
  return []
166
175
  }
167
- const free = this.capacity - this.messages.length - this.messagesChunk.length
176
+ const free = this.capacity <= 0
177
+ ? this.state.takers.size
178
+ : this.capacity - this.messages.length - this.messagesChunk.length
168
179
  if (free === 0) {
169
180
  return Arr.fromIterable(messages)
170
181
  }
@@ -274,6 +285,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
274
285
  message = this.messages[0]
275
286
  this.messagesChunk = Chunk.drop(Chunk.unsafeFromArray(this.messages), 1)
276
287
  this.messages = []
288
+ } else if (this.capacity <= 0 && this.state.offers.size > 0) {
289
+ this.capacity = 1
290
+ this.releaseCapacity()
291
+ this.capacity = 0
292
+ return this.messages.length > 0 ? core.exitSucceed(this.messages.pop()!) : undefined
277
293
  } else {
278
294
  return undefined
279
295
  }
@@ -422,6 +438,11 @@ class MailboxImpl<A, E> extends Effectable.Class<readonly [messages: Chunk.Chunk
422
438
  const messages = Chunk.unsafeFromArray(this.messages)
423
439
  this.messages = []
424
440
  return messages
441
+ } else if (this.state._tag !== "Done" && this.state.offers.size > 0) {
442
+ this.capacity = 1
443
+ this.releaseCapacity()
444
+ this.capacity = 0
445
+ return Chunk.of(this.messages.pop()!)
425
446
  }
426
447
  return empty
427
448
  }
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.10.15"
1
+ let moduleVersion = "3.10.16"
2
2
 
3
3
  export const getCurrentVersion = () => moduleVersion
4
4