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 8830339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:03:37+00:00 2026-06-14T08:03:37+00:00

Comparing the source code of clojure.lang.Ref and clojure.lang.Atom , I see that they both

  • 0

Comparing the source code of clojure.lang.Ref and clojure.lang.Atom, I see that they both inherit from clojure.lang.ARef.

In clojure.lang.ARef there is a function notifyWatches which lets all the watch function know that a change has been made.

the swap! and reset! functions in clojure.lang.Atom calls notifyWatches in its implementation.

eg.

public Object swap(IFn f) {
for(; ;)
    {
    Object v = deref();
    Object newv = f.invoke(v);
    validate(newv);
    if(state.compareAndSet(v, newv))
        {
        notifyWatches(v, newv);
        return newv;
        }
    }
 }

However, when I do a search for notifyWatches in clojure.lang.Ref, it comes up with nothing. The alter function looks like this.

public Object alter(IFn fn, ISeq args) {
   LockingTransaction t = LockingTransaction.getEx();
   return t.doSet(this, fn.applyTo(RT.cons(t.doGet(this), args)));
}

How do all the watch functions of a ref get notified if none of the methods are calling notifyWatches?

  • 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-14T08:03:38+00:00Added an answer on June 14, 2026 at 8:03 am

    The call to notifyWatches you are looking for occurs in the run method of the LockingTransaction class.

    Changes to refs happen in transactions. Note that the call to the doSet method of LockingTransaction is passed this (a reference to the Ref). The change that will be applied within the transaction is established by the doSet method but that change is effected within the run method of LockingTransaction. When the transaction is run successfully notifyWatches is called using the reference to the Ref recorded by doSet.

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

Sidebar

Related Questions

Looking at clojure.test source code , I spotted the following: (defonce ^:dynamic ^{:doc True
Comparing the HashMap and Hashtable source code in JDK 1.6, I saw the below
I disassembled the code resulting from compiling the very simple source file test.c, which
After compiling PHP from source are the devel libraries still needed? For example, I
Why comparing to null is so unstable? Just code. IronRuby 0.9.4.0 on .NET 2.0.50727.4927
I need help with comparing a column to a string. There is a column
[continued from Is there a way to tell whether two COM interface references point
Current problem: Target is to copy data from a source .csv file to a
I have a game source code but I could not assemble it on nasm
What is the best way of comparing that my image saved to a database

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.