Skip to main content
17 events
when toggle format what by license comment
Jan 23, 2023 at 0:00 history tweeted twitter.com/StackSoftEng/status/1617311172100759554
Jan 21, 2023 at 9:43 answer added Jason Weber timeline score: 1
Jan 18, 2023 at 22:56 answer added JimmyJames timeline score: 2
Jan 18, 2023 at 20:57 comment added Violet Giraffe @JimmyJames, sure!
Jan 18, 2023 at 20:40 comment added JimmyJames Would an answer in Java suffice? I haven't touched C++ in over two decades.
Jan 18, 2023 at 20:39 comment added Violet Giraffe @JimmyJames: they are available, and using or creating the specific synchronization primitive is not a problem. The question is how to express this neatly, in a way that's easy to understand and reason about.
Jan 18, 2023 at 20:36 comment added JimmyJames If I were doing something like this in Java, I would probably end up using some combination of Semaphores, CountDownLatches, and/or CyclicBarriers I take it that these kinds of concurrency primitives are not available to you. You might be able to create something similar by looking at the source for these.
Jan 18, 2023 at 18:35 comment added Ben Cottrell @VioletGiraffe given that the solution is already threaded, one additional (long-running) thread is very unlikely to make any difference, on the basis that you're already paying the premium for splitting work across threads and a buffer to synchronise them, so the additional thread is effectively "free" at this point. You might consider a thread pool if you want to save creating/deleting threads for new calls to f().
Jan 17, 2023 at 20:09 comment added Violet Giraffe @candied_orange: it should wait for some other thread to process and empty the buffer. This on its own should not be complicated, at least I don't think it will be.
Jan 17, 2023 at 19:43 comment added candied_orange When a thread calls the buffer as it's filling up what does the thread do with the data that it can't send to the buffer since it filled it up?
Jan 17, 2023 at 19:23 comment added Violet Giraffe @BenCottrell: you're right, and there is no reason in terms of functionality, only for efficiency. And the concept itself seems interesting enough to explore.
Jan 17, 2023 at 18:32 comment added Ben Cottrell Is there any particular reason why the thread which calls process() has to be one of the threads which called f()? It sounds to me as if process() makes more sense on an entirely separate thread whose responsibility is for deciding if/when to call process() and act as a consumer/controller for the buffer.
Jan 17, 2023 at 18:07 answer added Pablo H timeline score: 1
Jan 17, 2023 at 17:59 comment added Pablo H What's the relationship (temporal, call/callee, etc.) between calling f() and adding data to the buffer?
Jan 17, 2023 at 17:42 comment added Violet Giraffe @user253751: an interesting idea for sure, but once_flag cannot be reset.
Jan 17, 2023 at 16:38 review Close votes
Jan 22, 2023 at 3:06
Jan 17, 2023 at 15:59 history asked Violet Giraffe CC BY-SA 4.0