Skip to content

Textmate thread safe #24

Description

@spf-oss

Calling "grammar.TokenizeLine(line,rulestack)" by two threads at the same time will cause thread safety problems. How do you solve them?

Activity

  1. danipen commented on Jun 23, 2022

    @danipen
    Owner

    Each AvaloniaEdit instance uses one intance of the TMModel class to manage multithreading.

    It launches only one thread per grammar.

  2. spf-oss commented on Jun 25, 2022

    @spf-oss
    Author

    If I want to achieve the effect of vscode, when the code is very long, first of all, one thread of vscode will refresh the code color from the code in the visual area (the color may be wrong at this time), and then another thread will refresh the color from changing the position. At this time, there will be a phenomenon that the syntax starts two threads.

    In this way, you can achieve the rapid response of code color and ensure the correctness after refreshing.

    What should I do to achieve this effect?

  3. danipen commented on Jun 25, 2022

    @danipen
    Owner

    Well this behavior is already implemented in AvaloniaEdit and it's working fine. Take a look.

    It parses the viewport in the UI thread and starts parsing the document in a bg thread. Every time the viewport is scrolled, the view port is re-parsed.

  4. Repository owner locked and limited conversation to collaborators on Jun 28, 2022
  5. converted this issue into a discussion #25 on Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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