This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-28
Channels
- # admin-announcements (59)
- # aws (27)
- # beginners (42)
- # boot (22)
- # cider (5)
- # clojure (97)
- # clojure-australia (3)
- # clojure-italy (2)
- # clojure-japan (9)
- # clojure-russia (81)
- # clojure-sg (2)
- # clojurescript (86)
- # clojutre (1)
- # cloxp (2)
- # cursive (60)
- # datomic (24)
- # docs (1)
- # editors (1)
- # emacs (17)
- # hoplon (57)
- # instaparse (1)
- # jobs (11)
- # ldnclj (19)
- # re-frame (1)
- # reagent (3)
- # spacemacs (7)
- # testing (8)
- # yada (127)
Good morning.
Does anybody have a recommendation on libraries to make a pool of resources in Clojure? My goal is to have some objects that are slow to create, so I want to re-use them over time, but they are not thread safe, so no two threads should be using one at the same time.
@thomas: they are.
thomas: do you mean locking? https://clojuredocs.org/clojure.core/locking
thomas: I’m not writing the Java code.
And I’d rather not add Java code.
I’m just using one of these: http://docs.oracle.com/javase/7/docs/api/javax/script/ScriptEngine.html
pupeno: the very simplest option would be a lazily created thread-local (via a dynamic var or wrapping java.lang.ThreadLocal ... otherwise there seem to be a few clojure pools on github, though since one is by ztellman you should probably use that one : https://github.com/ztellman/dirigiste
Yeah, I though thread local would work, but jetty seems to be spawning new threads per each request, they don’t get re-used, so it kills the goal of re-usability.
jetty can certainly use a threadpool - http://www.eclipse.org/jetty/documentation/current/quickstart-config-what.html#intro-jetty-configuration-server
mccraigmccraig: my library can’t depend on a particular jetty configuration.
@pupeno: apache commons pool might be worth a look: https://commons.apache.org/proper/commons-pool/
ragge: I’m using aleph.flow