Difference between revisions of "Talk:Transactions"
m (→Examples please) |
(→Examples) |
||
Line 9: | Line 9: | ||
Transactions are assured with transactional memory, probably implemented as software transactional memory. | Transactions are assured with transactional memory, probably implemented as software transactional memory. | ||
− | + | ---------------- | |
Example of transaction:<br/> | Example of transaction:<br/> | ||
feature<br/> | feature<br/> | ||
Line 22: | Line 22: | ||
This feature is assured to be correct because is is isolated and atomic with respect to the system. If the container has been modified between the call to is_empty and remove, the feature would be aborted and retried. | This feature is assured to be correct because is is isolated and atomic with respect to the system. If the container has been modified between the call to is_empty and remove, the feature would be aborted and retried. | ||
+ | ----------------- | ||
+ | ----------------- | ||
feature<br/> | feature<br/> | ||
incorrect_removal(container: DISPENSER) is<br/> | incorrect_removal(container: DISPENSER) is<br/> | ||
Line 34: | Line 36: | ||
This is the standard example of concurrency issues with preconditions. The container can change between the call to is_empty and remove. Using transactions avoids this. | This is the standard example of concurrency issues with preconditions. The container can change between the call to is_empty and remove. Using transactions avoids this. | ||
+ | ---------------- | ||
+ | ---------------- | ||
Example of concurrency:<br/> | Example of concurrency:<br/> | ||
feature<br/> | feature<br/> | ||
Line 46: | Line 50: | ||
Since all feature calls would be asynchronous, the four write_file features could be executed in parallel if the runtime decides to do so. This is not a transaction so isolation across these calls is not assured. | Since all feature calls would be asynchronous, the four write_file features could be executed in parallel if the runtime decides to do so. This is not a transaction so isolation across these calls is not assured. | ||
+ | ---------------- | ||
+ | |||
+ | ---------------- | ||
+ | feature<br/> | ||
+ | write_file is<br/> | ||
+ | external<br/> | ||
+ | "operating_system_write"<br/> | ||
+ | abort<br/> | ||
+ | "operating_system_abort"<br/> | ||
+ | commit<br/> | ||
+ | "operating_system_commit"<br/> | ||
+ | |||
+ | This is how transactional features can be mapped on to external function calls that support transactional operations | ||
+ | ---------------- |
Revision as of 10:39, 6 April 2007
Discussion of the feasibility and desirability of implementing transactional concurrency in Eiffel.
Examples please
I think we need to see some examples (well, I do for one).
Examples
The main thing to remember is that the proposal states that all features calls are asynchronous.
Transactions are assured with transactional memory, probably implemented as software transactional memory.
Example of transaction:
feature
correct_removal(container: DISPENSER) is
transaction -- This is a transaction so it is assured to be atomic and isolated
if
not(container.is_empty)
then
container.remove
end
end
This feature is assured to be correct because is is isolated and atomic with respect to the system. If the container has been modified between the call to is_empty and remove, the feature would be aborted and retried.
feature
incorrect_removal(container: DISPENSER) is
do
if
not(container.is_empty)
then
container.remove
end
end
This is the standard example of concurrency issues with preconditions. The container can change between the call to is_empty and remove. Using transactions avoids this.
Example of concurrency:
feature
write_all_files is
do
write_file_1
write_file_2
write_file_3
write_file_4
end
Since all feature calls would be asynchronous, the four write_file features could be executed in parallel if the runtime decides to do so. This is not a transaction so isolation across these calls is not assured.
feature
write_file is
external
"operating_system_write"
abort
"operating_system_abort"
commit
"operating_system_commit"
This is how transactional features can be mapped on to external function calls that support transactional operations