Skip to content

Commit

Permalink
Update handlers.lua
Browse files Browse the repository at this point in the history
`Handlers.once` does a `prepend`: these should be higher priority than fallback handles. 

Use case: worker pool.
- Scenario 1: The master process resets a workers "busy" status upon receiving a "Ready" message.
- Scenario 2: When the all workers are busy, the master process should suspend by doing `Receive` on (any) workers "Ready" message. Resuming the thread should take priority over resetting the status as in Scenario 1
  • Loading branch information
elliotsayes authored Oct 21, 2024
1 parent f6d2739 commit cabd3a0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions process/handlers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function handlers.once(...)
pattern = select(1, ...)
handle = select(2, ...)
end
handlers.add(name, pattern, handle, 1)
handlers.prepend(name, pattern, handle, 1)
end

function handlers.add(...)
Expand Down Expand Up @@ -305,4 +305,4 @@ function handlers.evaluate(msg, env)
end
end

return handlers
return handlers

0 comments on commit cabd3a0

Please sign in to comment.