Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using transactions from multiple threads #57

Open
rhishikeshj opened this issue Apr 12, 2020 · 1 comment
Open

Using transactions from multiple threads #57

rhishikeshj opened this issue Apr 12, 2020 · 1 comment

Comments

@rhishikeshj
Copy link

Hi,
I am trying to use the STM system to run simultaneous transactions from multiple threads.
Unfortunately it seems either my usage is incorrect, or my understanding of the API is.
Can you please help me out ?

Code :

for _ in 1...3 {
    Thread {
	let _ =
		transfer(from: alice, to: bob, amount: 100)
		.then(transfer(from: bob, to: alice, amount: 20))
		.then(deposit(into: bob, amount: 1000))
		.then(transfer(from: bob, to: alice, amount: 500))
		.atomically()
    }.start()
}

Result :
If fails on this pre-condition

precondition(transactionEnterSucceed, "Transaction already running on current thread")

@wentingliu
Copy link

@rhishikeshj The simple translation from F# didn't work, I'm working on a independent implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants