Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Maybe we can make name optional? |
|
I would avoid having conditional mutexes, we can always achieve that by using await + mutex |
+1 to both of these. I was going to say don't do name at all, but then I saw PHP's built-in mutex takes a name which I find really odd, but, I agree it makes sense to match that API. As for the conditional, yeah, user can always use await & we haven't provided that in other langs either so we can stick with the basic APIs. The only other thing I would add is a |
We can definitely get rid of the name. SyncMutex is not a PHP standard; it's just a third-party extension, and we don't have to consider it. |
|
PR updated according to the review If we don't use the mutex name, we can simplify everything:
|
|
This approach is looking good to me 👍 |
# Conflicts: # src/Workflow/WorkflowContextInterface.php
What was changed
Added a new class Mutex.
The Mutex class has a
lock()method that returns a Promise. This meansyield $mutex->lock()will wait for the lock is acquired.The Mutex class also has
tryLock(),unlock(), andisLocked()methods, which do not imply Await behavior.Added
Workflow::runLocked(Mutex $mutex, callable $callable): PromiseInterface:Executes a function if the given Mutex is not locked and locks the Mutex for the duration of the function's execution.
Checklist
An explanation