4 ms·
One very important aspect of Clojure is lock-less, STM(software transactional memory) based concurrency that just works. In clojure, shared memory is readily av
by titanix88 9y ago
One very important aspect of Clojure is lock-less, STM(software transactional memory) based concurrency that just works. In clojure, shared memory is readily available and with a few lines of code, you can get rid of entire third party projects typically used for in-memory caching, message-passing and background job processing. This is a huge win if you are writing long running server applications.
- flavio81 9y ago>readily available and with a few lines of code 1. Declare the classes you want to work under transactional memory as transactional... by wrapping them in such a way: (transactional (defclass ...)) 2. Whenever you need to do a STM transaction, just wrap the critical code within (atomic): (atomic (do-stuff ... )) Is it hard? Nope. The above example is one easy way to do it in Common Lisp, using the STMX library, which of course you can download, compile and load with one line of code: (ql:quickload "stmx") So yes, it is easy under Clojure, but not only in Clojure.