No concurrency safe
От: igor-booch Россия  
Дата: 12.03.19 09:43
Оценка:
A>The solution is no concurrency safe — transaction is not atomic
A> me — there is no explicit requirement and actually basic
A>transaction (add) is atomic. There is no race conditions. Atomicity of
A>_transfer_ is required if we don't want to loose data — but here there
A>is no such problem since we don;t store anything between sessions.

А если:

    override fun transfer(from: String, to: String, amount: BigDecimal) {

        val amt = amount.abs()

        add(from, amt.negate())


// Здесь кто-то запросит list, и получит ответ ???!!!!

        try {
            add(to, amt)
        }
        catch (e: Exception) {
            add(from, amt) //unlikely we will have overflow here
            throw e
        }
}


получит противоречивые данные.
Так что не concurrency safe.
http://rsdn.ru/Info/rules.xml
Отредактировано 12.03.2019 9:45 igor-booch . Предыдущая версия .
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.