@@ -172,8 +172,8 @@ trait GenConcurrent[F[_], E] extends GenSpawn[F, E] {
172172 case None =>
173173 F .uncancelable { poll =>
174174 F .deferred[Outcome [F , E , B ]] flatMap { result =>
175- // laziness is significant here, since it pushes the `f` into the fiber
176- val action = poll(sem.acquire) >> f(a)
175+ // the laziness is a poor mans defer; this ensures the f gets pushed to the fiber
176+ val action = poll(sem.acquire) *> ( F .unit >> f(a) )
177177 .guaranteeCase { oc =>
178178 val completion = oc match {
179179 case Outcome .Succeeded (_) =>
@@ -265,7 +265,8 @@ trait GenConcurrent[F[_], E] extends GenSpawn[F, E] {
265265 case None =>
266266 F .uncancelable { poll =>
267267 // if the effect produces a non-success, race to kill all the rest
268- val wrapped = f(a) guaranteeCase {
268+ // the laziness is a poor mans defer; this ensures the f gets pushed to the fiber
269+ val wrapped = (F .unit >> f(a)) guaranteeCase {
269270 case Outcome .Succeeded (_) =>
270271 F .unit
271272
@@ -278,8 +279,7 @@ trait GenConcurrent[F[_], E] extends GenSpawn[F, E] {
278279
279280 val suppressed = wrapped.void.voidError.guarantee(sem.release)
280281
281- // the laziness is significant here since it pushes the f into the fiber
282- poll(sem.acquire) >> suppressed.start flatMap { fiber =>
282+ poll(sem.acquire) *> suppressed.start flatMap { fiber =>
283283 // supervision is handled very differently here: we never remove from the set
284284 supervision.update(fiber :: _)
285285 }
0 commit comments