guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

question about atomics


From: joakim
Subject: question about atomics
Date: Fri, 26 May 2017 12:37:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Hello,

I'm making a simple program that processes a lot of mail in separate
guile threads.

I would like a counter of how many messages have been processed so I made an 
attempt with
atomics.

first:
    (define *msgcount* (make-atomic-box 0))

and later:
    (atomic-box-swap! *msgcount* (+ 1 (atomic-box-ref *msgcount*)))

This of course doesn't work very well, and I didnt expect it to either.
(usually the count is low by a couple of hundred messages)

So basically, how do I get something similar to the swap! function in
clojure? Did I miss something in the documentation for guiles atomics?

I think I expected to be able to do the following:
    (atomic-box-swap! *msgcount* (lambda (atom) (+ 1 (atomic-box-ref atom))))

-- 
Joakim Verona
address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]