openframeworks / openframeworks/openFrameworks
exposing queue size for ofThreadChannel
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
I have an application where a thread produces output in bursts (e.g., 500 items every 2 seconds). I send this back to the main thread via an ofThreadChannel. If I process all the available messages at once, the main thread stalls. If I process only one message, then the queue gets backed up. So I'd like to process a maximum of 10% of the data every frame, which will mean the queue never gets backed up and the main thread never stalls. So I would need something like:
unsigned int queueSize() const {
return queue.size();
}
There's no use of having a scoped lock, because the data could be incorrect by the time it gets back to the main thread, but at least we will have an estimate of whether to continue using tryReceive() or not.
Does this seem like a worthwhile addition?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ofThreadChannel implementation and reading how queue and tryReceive() are defined and used. Determine where a queue-size estimate can be exposed without implying synchronized accuracy. Done means callers can query the approximate pending message count while processing messages incrementally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100