Concurrency: how to shoot yourself in both feet. Simultaneously.

778 views

Published on

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
778
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Concurrency: how to shoot yourself in both feet. Simultaneously.

  1. 1. Concurrency How to shoot yourself in both feet. Simultaneously.Victor HaydinR&D Manager @ ELEKS
  2. 2. The Problem
  3. 3. Multithreading? Parallelism? Concurrency?
  4. 4. Concurrent programming* * as you imagine it
  5. 5. * in real world
  6. 6. Shared state
  7. 7. Traditional way
  8. 8. WTF?!
  9. 9. Web 2.0 – 2003First dual-core CPU – 2005 Cloud Computing - 2006
  10. 10. C++ - 1983Java - 1995 C# - 2001
  11. 11. Alternate ways
  12. 12. Transactional memoryFunctional programming Messaging
  13. 13. atomic { if (from.Ballance < amount) throw new InsufficientBalanceException("Not enough money"); from.Debit(amount); to.Credit(amount);}
  14. 14. Atomic.Do(() => { if (from.Ballance < amount) throw new InsufficientBalanceException("Not enough money"); from.Debit(amount); to.Credit(amount);});
  15. 15. STM HTM
  16. 16. Immutable data means no side effects. No side effects – no concurrency problems!* * except if you need I/O
  17. 17. Wait a second, what about I/O?
  18. 18. FP != easy concurrencyFP == easy parallelism
  19. 19. NAct StactRetlang
  20. 20. …or use single thread.
  21. 21. Q&A

×