https://github.com/thedmi/capsule
Automatic thread-safe objects for .NET
https://github.com/thedmi/capsule
actor-model csharp run-to-completion state-machine thread-safety
Last synced: 2 months ago
JSON representation
Automatic thread-safe objects for .NET
- Host: GitHub
- URL: https://github.com/thedmi/capsule
- Owner: thedmi
- License: mit
- Created: 2024-01-07T19:22:53.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-07-03T15:27:49.000Z (3 months ago)
- Last Synced: 2025-07-03T16:29:15.093Z (3 months ago)
- Topics: actor-model, csharp, run-to-completion, state-machine, thread-safety
- Language: C#
- Homepage: https://thedmi.github.io/capsule/
- Size: 772 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Capsule

[](https://www.nuget.org/packages/Capsule.Core/)
[](https://www.nuget.org/packages/Capsule.Generator/)
[](https://www.nuget.org/packages/Capsule.Testing/)Capsule is a .NET library and C# source generator that provides thread-safe object encapsulation in an automatic and boilerplate-free way. It can be used as run-to-completion runtime for state machines, as actor library or just to avoid manual locking and synchronization code.
Capsule turns ordinary objects into thread-safe *capsules*. A capsule can be used *concurrently* without the risk of race conditions. The original interface is retained, so this is *transparent* for callers.

To create a capsule, you provide an implementation (green) and specify how the methods and properties (yellow) are to be encapsulated. Capsule then adds synchronization infrastructure (blue) and the hull (red), a generated interface adapter.
Apart from a few attributes and the requirement to make methods `async`, implementations remain free of synchronization code. This keeps code readable and focused. It also improves testability because synchronization concerns are separated.
See [docs](https://thedmi.github.io/capsule) for more information.