Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Optimzed loop #60

Open
elgopher opened this issue Jan 12, 2020 · 0 comments
Open

Optimzed loop #60

elgopher opened this issue Jan 12, 2020 · 0 comments
Labels
help wanted Extra attention is needed thinking Thinking

Comments

@elgopher
Copy link
Owner

elgopher commented Jan 12, 2020

There is a chance that a single frame processing will take more time than expected. The usual cause of the problem might be an inefficient image manipulation. But some pieces of code in the loop have to be executed in timely manner. One such piece is an input handling.

My initial idea is to create a new kind of optimzed loop which will support multiple callbacks, each executed at his own pace:

optimizedLoop := loop.NewOptimizedLoop(window)
// this function gets called at normal rate (at most 60 times per second)
optimizedLoop.Set(60, func(frame *pixiq.Frame) {
     // here goes the input processing
})
// this function gets called at lower rate (at most 30 times per second)
optimizedLoop.Set(30, func(frame *pixiq.Frame) {
     // here goes the screen draw
})
optimizedLoop.Execute()
@elgopher elgopher added help wanted Extra attention is needed thinking Thinking labels Jan 12, 2020
@elgopher elgopher changed the title Design an optimzed loop Optimzed loop Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed thinking Thinking
Projects
None yet
Development

No branches or pull requests

1 participant