Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8624319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:29:57+00:00 2026-06-12T07:29:57+00:00

I’m working on a chatbot for Campfire that holds the current users list in

  • 0

I’m working on a chatbot for Campfire that holds the current users list in an atom, (defonce users (atom {})).

I originally picked this reference type due to its simplicity, and it’s worked well up till now, but that might need to change.

  1. Campfire sends EnterMessage and LeaveMessage events to the streaming api. My bot reacts to these by fetching the the current users list from the Campfire API, then calling reset! on the users atom with the new list.

  2. Those same Enter/Leave events trigger random interactions, such as picking a random user from the users atom and asking it a question.

Problem

Number 2 above often asks the user who just left or never asks the user who just entered because the users atom hasn’t yet been !reset. I think I need to use a ref, but these docs say “Writers will never block commuters, or readers.” The thing is, I want that writer to block my reader, right?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:29:58+00:00Added an answer on June 12, 2026 at 7:29 am

    refs are primarily designed for coordinated access to several data structures if you only have one identity (the user list) then the main advantage of refs is not really an advantage to you, although it is not really a problem either. Refs have a cost as well in that transactions may be run more than once, so if your actions have side effects like sending messages then messages could be sent twice on transaction retries. You can get around this by using both a ref and an agent because messages sent to an agent from a transactions are guaranteed to send exactly once and only with the final committed values.

    in your case you could do well by:

    • continuing to use an atom
    • use somethign like (swap! users assoc name user) to incrementally build the user list.
    • use a watch function on the atom to handle the state changes, because watches will catch every state change.

    or

    • switch to a ref
    • use an agent to sent the actual messages to users.
    • using a watch could make this simpler but is not required.

    The quote "Writers will never block commuters, or readers." may not be directly relevant to you though it’s worth explaining a bit. In the case of a single ref, a thread that simply reads the value of the ref never waits, it gets the current value and continues. When there are more than one ref, it can read them both within a transaction and get a guarantee that it will either get a consistent set of values from both of them or will be rerun until it does get a consistent set of values. Threads that need to update the values will similarly need to rerun if they don’t get a consistent set of values, unless they are using the commute function to update them in which case the STM will know that it is safe to commit the new value even is some other thread also did the same (or also commutable) operation to the value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.