title: How to guard a mutable object against concurrent read/write access in Clojure?
body: <p>I'm using <code>jgrapht</code>, a graph library for java as the backbone of my graph operations. It mutates its state on every change, like adding or removing an edge or a vertex.</p>
  
  <p>I'm accessing this "object" from multiple threads / go-loops.</p>
  
  <p>I've started naively wrapping the graph object with an atom but as far as I understand, it doesn't protect (and can't do) against directly changing the state of its content. Its a safeguard only if you are able to use <code>reset!</code> or <code>swap!</code> functions.</p>
  
  <p>I've changed to <code>ref</code>s and started doing my mutations in <code>dosync</code> blocks but I still notice some weird behaviour from time to time. They are hard to pinpoint since they appear on runtime. As you would expect.</p>
  
  <p>I'm not experienced in Clojure ecosystem, so I'd appreciate if you can point me into a couple of alternative strategies for dealing with stateful objects from Java in Clojure.</p>
  
  <p>PS: I'm aware of <code>loom</code> and would love to use it, but it lacks for my most important requirement: <em>finding all simple cycles in a weighted directed graph with negative weights</em>.  </p>