Fork me on GitHub
#ldnclj
<
2016-02-04
>
xlevus14:02:17

is there a pattern/lib/datastructure to handle rapidly changing hash sets? I've got two incoming streams of data. One a stream of channels, and the other a stream of packets for those channels... I receive a channel, and then shortly after I expect a data packet for that given channel. Currently I'm just storing the channels in an atom containing a map and doing swap! constantly.

xlevus14:02:46

is there a better way. Seems kinda... clunky?

mccraigmccraig14:02:17

so you get a channel (with an id of some sort?) and then a packet for the channel (also with an id for channel?) put the packet on the channel, then what happens to the channel ? close or await further packets ?

mccraigmccraig14:02:49

atom/swap! doesn't seem unreasonable to me... agents could also be useful, though unless you need the STM stuff they probably aren't doing anything for you over atom/swap!

xlevus14:02:06

hmm. ok. ta

mccraigmccraig14:02:29

though agents do the thread-pool stuff themselves, so that may be useful

mccraigmccraig14:02:11

and if you are on cljs rather than clj then there is only atom simple_smile

xlevus14:02:34

yeah, this is actual-clojure

xlevus14:02:47

will look into agents tho, sounds like it might make it cleaner

xlevus14:02:22

well that was easy

xlevus15:02:38

yeah, and the channel-matching