Skip to content

resetCycles should be (more) immediate #1197

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

Open
yaxu opened this issue May 14, 2025 · 2 comments
Open

resetCycles should be (more) immediate #1197

yaxu opened this issue May 14, 2025 · 2 comments

Comments

@yaxu
Copy link
Member

yaxu commented May 14, 2025

resetCycles resets the start time (to 'now') and tick count (to 0), so could in theory happen at now+latency time, regardless of the value of cFrameTimespan.

However if cFrameTimespan is set to e.g. 1, there is an unpredictable delay of between 0 and 1 seconds on top of latency. This seems to because the thread is delayed in the tick function, and so no input is processed between frames.

Instead of using threadDelay, it seems it's possible to do timeouts with STM. So tidal could wait for an action to process until the end of the frame.

I've not done any work with STM before and it looks like this would need an adjustment to how the queue is done currently? In the current implementation the TVar always contains a value so there's nothing to 'wait' for (without continuously polling for something other than a NoAction).

Does that sound like a reasonable analysis @Zalastax ?

@yaxu
Copy link
Member Author

yaxu commented May 14, 2025

It seems I misunderstood how registerDelay works. It creates a separate state variable, and you somehow combine it with your STM action to create the timeout:
https://gist.github.com/qnikst/2762191

But still I think the model needs adjusting so that there can be a read action that times out if there isn't a new action.

@yaxu
Copy link
Member Author

yaxu commented May 14, 2025

As a first step I switched to TQueue in #1198

I'm not entirely sure what I'm doing but this, I'm not sure of drawbacks but should allow a blocking call with timeout.

Using registerDelay will also require compiling with -threaded, I'm not sure if there are drawbacks to that either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant