From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Olivier Dion via General Guile related discussions Newsgroups: gmane.lisp.guile.user Subject: Support for more atomic operations Date: Thu, 25 Nov 2021 10:27:40 -0500 Message-ID: <87fsrk9rwz.fsf@laura> Reply-To: Olivier Dion Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22415"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Thu Nov 25 16:28:04 2021 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mqGfL-0005iV-Rt for guile-user@m.gmane-mx.org; Thu, 25 Nov 2021 16:28:03 +0100 Original-Received: from localhost ([::1]:57506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqGfK-0008WJ-Ie for guile-user@m.gmane-mx.org; Thu, 25 Nov 2021 10:28:02 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqGf8-0008Vt-GG for guile-user@gnu.org; Thu, 25 Nov 2021 10:27:50 -0500 Original-Received: from smtp.polymtl.ca ([132.207.4.11]:48109) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqGf5-0008Av-Jn for guile-user@gnu.org; Thu, 25 Nov 2021 10:27:49 -0500 Original-Received: from localhost (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 1APFRfTC012001 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 25 Nov 2021 10:27:45 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 1APFRfTC012001 X-Poly-FromMTA: (modemcable094.169-200-24.mc.videotron.ca [24.200.169.94]) at Thu, 25 Nov 2021 15:27:41 +0000 Received-SPF: pass client-ip=132.207.4.11; envelope-from=olivier.dion@polymtl.ca; helo=smtp.polymtl.ca X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:17832 Archived-At: Hi! Does anyone know if Guile plans to have better support for atomic operations? For example `atomic-box-fetch-and-add!`. I know that in theory, one can do the following: ------------------------------------------------------------------------------ (define (atomic-box-fetch-and-apply! box op value) (let ([old (atomic-box-ref box)]) (if (eq? old (atomic-box-compare-and-swap! box old (op old value))) old (atomic-box-fetch-and-apply! box op value)))) (define (atomic-box-fetch-and-add! box value) (atomic-box-fetch-and-apply! box + value)) (define (atomic-box-fetch-and-sub! box value) (atomic-box-fetch-and-apply! box - value)) (define (atomic-box-fetch-and-xor! box value) (atomic-box-fetch-and-apply! box logxor value)) ... ------------------------------------------------------------------------------ and it works. But I think such operations would be faster if available as primitives in the VM, if that's possible? -- Olivier Dion Polymtl