NoteBlockAPI icon indicating copy to clipboard operation
NoteBlockAPI copied to clipboard

Use limited number of threads

Open koca2000 opened this issue 1 year ago • 2 comments

NoteBlockAPI 1.x uses one platform thread for each SongPlayer even when the playback has not started yet. It is not very resource effective so a different solution should be used.

@Elecast2 proposed a solution with a single-threaded ticker in PR #119. However, this solution use fixed 10ms delay which in some cases may not be precise enough and in other situations it does unnecessary work. Also it serialize SongPlayers into a queue and so e.g. an event in one of the SongPlayers may delay playback of the others.

I like the idea of the SongTicker or custom ExecutorService, but it has to be done in a way that one SongPlayer doesn't affect the others. Something like a group of worker threads and a PriorityQueue.

koca2000 avatar Dec 29 '24 11:12 koca2000