News for hackers. Stuff that matters.
Re:Concurrency I can finally understand and write correctly by amarkov on Tuesday March 13, 2018 @05:42AM (#16574783)
Futures aren't a natural way to formulate many important concurrency problems. If I want a thread polling an external system and putting records in a work queue for as long as my application is running... well, what's that a future of?
Re:Concurrency I can finally understand and write correctly by sametmax on Tuesday March 13, 2018 @11:45AM (#16577063)
That's what thread pools are for. They have a work queue you fill and workers depop it. Literally 5 lines in python and i imagine most modern languages.
Re:Concurrency I can finally understand and write correctly by amarkov on Tuesday March 13, 2018 @12:13PM (#16577269)
Right, but thread pools are simple because they don't offer any sort of API for the tasks in the work queue. You're just writing arbitrary code. So rather than reasoning about an abstract execution model, you have to carefully think about every line to make sure you don't accidentally share mutable state.
Re:Concurrency I can finally understand and write correctly by therealdrag0 on Tuesday March 13, 2018 @01:39PM (#16577980)
In Java with Spring you'd do something like:

@Scheduled(fixedRate = 5000) public void poll() { getCrapAndPutOnConsumerQueue(); }