8000 Consider Refactoring link.rs · Issue #11 · terhechte/postsack · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Consider Refactoring link.rs #11
Open
@terhechte

Description

@terhechte

The link is a bit of a terrible abstraction to handle background threads via egui. The way it works is that when an action should be performed in the background, it will send the action over a crossbeam channel to a separate thread which continuously listens for input from the channel. The thread processes the action (e.g. performs a query) and sends it back.

Egui, in the default event loop, will check for any response in the receiver crossbeam channel (e.g. 30 times per second on 30fps). If a response is available it will be applied.

There're a couple of downsides to this:

  • Request and Response are separated which makes it very difficult to use the Engine via Link in a non-async context.
  • WASM doesn't support threads, so there is a wonky abstraction to allow sync access (with way too many cfg(target_arch = wasm32)
  • This solution requires multiple additional abstractions which make it all a bit confusing to understand.

Egui apparently would work from separate threads but this might not work for other UI libraries (if we ever port it). So maybe a solution would be to have a SyncLink and AsyncLink with a closure that makes sure the request matches the response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0