{"id":16752280,"url":"https://github.com/afranchuk/plugin_tls","last_synced_at":"2025-09-21T11:55:39.194Z","repository":{"id":57656420,"uuid":"317605613","full_name":"afranchuk/plugin_tls","owner":"afranchuk","description":"Thread-local storage across dynamic library boundaries in rust.","archived":false,"fork":false,"pushed_at":"2022-08-24T14:26:03.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T13:37:24.947Z","etag":null,"topics":["plugin","plugins","rust","thread-local","thread-local-storage"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/afranchuk.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-01T16:43:06.000Z","updated_at":"2024-06-16T11:35:16.000Z","dependencies_parsed_at":"2022-08-26T05:11:39.602Z","dependency_job_id":null,"html_url":"https://github.com/afranchuk/plugin_tls","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afranchuk%2Fplugin_tls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afranchuk%2Fplugin_tls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afranchuk%2Fplugin_tls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/afranchuk%2Fplugin_tls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/afranchuk","download_url":"https://codeload.github.com/afranchuk/plugin_tls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248245303,"owners_count":21071457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plugin","plugins","rust","thread-local","thread-local-storage"],"created_at":"2024-10-13T02:46:32.476Z","updated_at":"2025-09-21T11:55:34.148Z","avatar_url":"https://github.com/afranchuk.png","language":"Rust","readme":"# plugin_tls\n\nThread-local and static-duration storage support across dynamic-library\nboundaries.\n\nNormally, a `std::thread::LocalKey` refers to a specific memory location in a\nsingle binary. This library adds support for thread-local storage across\nbinaries by storing thread-local values in a shared map between a host and one\nor more plugins.\n\nThe library also adds support for static-duration (but necessarily\nlazily-initialized) storage across binary boundaries, since such an\nimplementation is very similar to that of thread-local storage.\n\n## Use\n\nUse the `host` feature to enable the host capabilities (in exactly one binary to\nbe loaded in memory), and use the `plugin` feature to enable plugin capabilities\n(in zero or more binaries to be loaded).\n\nIn each plugin binary, call `Context::initialize` with the host context prior to\nany thread-local or static storage being accessed (typically as part of the\nbinary startup routine). The host binary will default to the correct state,\nhowever this may be overwritten with `initialize` as well.\n\nBesides that, the `thread_local!` macro works exactly like `std::thread_local!`\nfor both the host and plugins, and `lazy_static!` works exactly like the\n`lazy_static` crate. Note that thread-local and static values are indexed by the\ngiven name, type, and module path, so these _must not_ conflict. Also note that\nstored values _must_ be abi-stable. Abi-stability is not enforced in `LocalKey`\n(e.g. with the `abi_stable::StableAbi` trait) for library flexibility, but use\nof the `abi_stable` crate is highly encouraged.\n\nNote that both `host` and `plugin` may be enabled together, specifically for use\nin workspaces that may contain both the host and plugin(s).\n\n## Safety\nIf unloading plugins, one must ensure that any memory set by plugins in\nthread-local or static storage is removed (including any initial values!). In\nthe future there could be additions to track which initial values are created by\na particular plugin, but for now one solution is for the host to call\n`Context::reset` to clear all thread-local and static values.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafranchuk%2Fplugin_tls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafranchuk%2Fplugin_tls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafranchuk%2Fplugin_tls/lists"}