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

Refactor context task to allow asynchronous dispose #132

Merged
merged 3 commits into from
Jul 24, 2024
Merged

Conversation

glopesdev
Copy link
Collaborator

The current implementation of ContextTask is blocking with respect to both register access, start and stop of acquisition and context disposal, with a significant amount of state shared across calls.

Here we propose to refactor the implementation to eliminate almost all shared state, and instead redefine the acquisition task as a proper TPL task composed of two sub-tasks, readFramesand distributeFrames. This task can be cancelled asynchronously and therefore allows implementing a non-blocking version of the Dispose method which simply triggers acquisition task cancellation and prevents its restart.

StartAsync method calls are also meant to be mutually exclusive, so care was taken to prevent acquisition tasks to be called concurrently on the same context.

Fixes #131

@glopesdev glopesdev added the fix Pull request that fixes an issue label Jul 12, 2024
@glopesdev glopesdev added this to the 0.1.0 milestone Jul 12, 2024
@glopesdev glopesdev requested review from jonnew and aacuevas July 12, 2024 12:10
@jonnew
Copy link
Member

jonnew commented Jul 16, 2024

Tested with breakout hardware and few headstages. I don't see any unexpected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull request that fixes an issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deadlock when throwing register exceptions asynchronously
2 participants