This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-25
Channels
- # announcements (4)
- # beginners (26)
- # calva (18)
- # cider (24)
- # clojure (35)
- # clojure-brasil (9)
- # clojure-dev (6)
- # clojure-europe (39)
- # clojure-madison (1)
- # clojure-nl (1)
- # clojure-norway (100)
- # clojure-uk (6)
- # clojurescript (17)
- # data-science (15)
- # datalevin (5)
- # emacs (1)
- # events (2)
- # introduce-yourself (2)
- # javascript (1)
- # malli (28)
- # missionary (7)
- # off-topic (59)
- # polylith (20)
- # reitit (2)
- # releases (1)
- # remote-jobs (2)
- # rewrite-clj (5)
- # shadow-cljs (27)
- # sql (5)
- # squint (63)
- # xtdb (8)
Is initializing a semaphore with 0 tokens expected to work? (I'd expect this to wait at the m/?
, but 0 seems to act more like ##Inf)
(let [sem (m/sem 0)]
(m/? sem)
(println "acquired"))
acquired
I was working on a priority queue, where tasks are run one at a time, and when the current task has finished it pulls the highest priority task from the queue. So I needed a way of notifying when a new task had been added to the queue so that the task runner could unblock when the queue was no longer empty. An m/sem seemed like the simplest facility since no data needs to be transmitted, just that another task has been added; although it may be more than is needed since I don't need to count the number of messages in the queue, just whether it's empty or not. If I was going to use a sem I'd need to start at zero since the queue would initially be empty. But I switched to sending nil through an mbx which worked fine. I don't know anything about semaphores aside from reading the Missionary documentation on m/sem so I don't really have an opinion on what it should do, though if 0 is invalid that would be good to mention in the documentation.
curious about the design of missionary. the language-native dsl feels a lot simpler than monadic approach, but from a theoretical, abstract perspective, are there monads under the hood? would that be the correct mathematical framing?
I can't say about monads, but in terms of the design, https://github.com/leonoel/task and https://github.com/leonoel/flow are excellent references, if you haven't seen them already.