Skip to content

Using transactions from multiple threads #57

Description

@rhishikeshj

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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions