Hacker News new | ask | show | jobs
by bouk 3655 days ago
Seems like this is what mutexes were invented for
2 comments

The typical solidity dev is "but mutexes cost so much gas!"

There's an optimization problem not yet sorted out here. If I were king of ethereum, (happily I'm not), I'd make a very cheap mutex support part of the eth vm and encourage solidity and serpent devs to use it as needed.

I suspect we'll see something like mutexes in the next ethereum EVM revision.
Yes, that would be a kind and fine thing to do, or at least change the cost of a specially designated bool argument to something cheap. You get one per contract, kind of thing. Or you pay on deployment.
With a mutex, an A -> B -> A call would deadlock if the mutex is the stop-and-wait or spin-and-retry sort. It would have to be a succeed-or-exception mutex, which is not a common design.
EVM doesn't allow the implementation of a blocking mutex and a "spin-and-retry" would simply run out of gas.
Keep in mind that Ethereum only runs one thread. It puts transactions in order and runs one after another.