Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorkQueue for background task #25

Open
cahirwpz opened this issue Sep 12, 2017 · 0 comments
Open

WorkQueue for background task #25

cahirwpz opened this issue Sep 12, 2017 · 0 comments

Comments

@cahirwpz
Copy link
Owner

cahirwpz commented Sep 12, 2017

To allow concurrent effect data loading (with Effect.Load) and rendering (with Effect.Render) the demo must be able to delegate work to a background task. Effect.Render must not busy-wait but use TaskWait(VBlankEvent) to leave some time for concurrent execution of Effect.Load. Use cases follow:

  • Initial phase of a demo:
WorkQueueT wq;
WorkT w1 = {.func = Effect1.Load};
...

WQInit(&wq);
WQAdd(&wq, &w1);
...

/* Loading screen... */
while (!WQIsEmpty(&wq)) {
  /* render frame */
  TaskWait(VBlankEvent); /* Switch out to background thread! */
}
  • Before every effect we need to make sure a job is DONE. This should suspend calling task if the job is RUNNING.
WQWaitFor(&w5);
/* Do the next effect. */
  • If user wants to quit demo, we need to cancel all READY jobs and wait for RUNNING job to finish.
WQDrain(&wq);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant