Skip to content

[Go] Add thread-safe serialization support for concurrent use #3017

@chaokunyang

Description

@chaokunyang

Feature Request

No response

Is your feature request related to a problem? Please describe

The current Fory instance is not thread-safe, requiring users to:

  • Manually manage Fory instances per goroutine
  • Implement their own pooling for performance
  • Risk data races if sharing instances

Describe the solution you'd like

Create a new fory/threadsafe package that:

  • Wraps Fory instances using sync.Pool for zero-contention concurrency
  • Provides the same API surface as the main package
  • Automatically manages instance lifecycle (acquire/release)
  • Includes both generic and non-generic APIs

Benefits

  • Safe concurrent use out of the box
  • Efficient pooling with automatic cleanup
  • No performance overhead for single-threaded use (still use main package)
  • Easy migration path for concurrent applications

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    goPull requests that update go code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions