Chocola is a Clojure library for concurrent and parallel programming. It provides futures, transactions, and actors. It is unique in ensuring that these three models work correctly even when they are combined.
You can find more information and code examples at https://chocola.jnwllm.be/.
Because this library monkey-patches Clojure, it is a bit complicated to get working: we need to make sure it is loaded before Clojure, i.e. the Chocola jar must appear earlier in the classpath than Clojure. Assuming you use Leiningen, you can follow these steps:
- In a temporary folder, checkout this repository and create the 'uberjar':
$ git clone https://github.com/jswalens/chocolalib.git
$ lein uberjar
This creates the file target/chocola-2.0.1-standalone.jar
, which contains Clojure 1.10.1, Chocola, and its dependencies (core.match).
-
Copy this file into the
resources
folder of your project. (The folder can have another name too.) -
Update your project's
project.clj
to add the following lines:
:resource-paths ["resources/chocola-2.0.1-standalone.jar"]
:injections [(require 'chocola.core)]
The first line will make sure that Chocola and its dependencies are loaded. The second line injects a call to include Chocola in your code, which will patch Clojure and modify its internals to use Chocola's semantics.
Some code examples of Chocola can be found at https://chocola.jnwllm.be/.
We published about (the ideas behind) Chocola in the following academic papers:
- Chocola: Composable Concurrency Language (TOPLAS, January 2021, also available here)
- Chocola: Integrating Futures, Actors, and Transactions (AGERE at SPLASH, November 2018)
- Transactional Tasks: Parallelism in Software Transactions (ECOOP, July 2016)
- Transactional Actors: Communication in Transactions (SEPS at SPLASH, October 2017)
You can find a lot more information in my PhD thesis.
If you use this software in an academic context, please cite the following paper:
@article{10.1145/3427201,
author = {Swalens, Janwillem and {De Koster}, Joeri and {De Meuter}, Wolfgang},
title = {{Chocola: Composable Concurrency Language}},
journal = {ACM Transactions on Programming Languages and Systems},
year = {2021},
month = jan,
volume = {42},
number = {4},
articleno = {17},
numpages = {56},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
issn = {0164-0925},
doi = {10.1145/3427201},
url = {https://doi.org/10.1145/3427201},
}
- Documentation:
- Check whether getting started always works as expected
- Add documentation on how to use Chocola and explain its semantics
- Implementation:
- Garbage collection of unreachable actors (currently, unreachable actors will stay idle forever)
- Interaction with exceptions/errors (seems to mostly work correctly, but exhaustive testing is needed)
-
commute
(doesn't work as expected in transactional futures) - Performance improvements (see TODOs throughout code)
Copyright © 2018–2019 Janwillem Swalens, Software Languages Lab, Vrije Universiteit Brussel. Distributed under the Eclipse Public License, included in the file LICENSE
.