Rust has task-local storage, which sounds like what you're looking for.
This example (http://bubblingbeebles.livejournal.com/111016.html) is a bit
old, I'm not sure it would still work.


On 21 May 2013 09:16, Kim HyunKang <[email protected]> wrote:

> Hello list.
>
> I'm a Rust newbie and I'm really excited about this language
>
> As a process of knowing each other, I'm implementing a libgit2 bindings
> for Rust. (You can look at the code at here:
> https://github.com/kimhyunkang/git2-rs  though it has virtually no
> features for now.)
>
> libgit2 uses thread local storage to store and retrieve error info from
> last library call. But the Rust tutorial states that tasks are considered
> green threads. As far as I can understand, that means tasks are not mapped
> 1:1 to OS thread, thus making thread-local storage unsafe for direct use.
>
> Then I rememberd errno, another thread local storage that I know of, and
> checked the source code to find out how core::os handles errno. But
> core::os::errno seems to just call __errno without locking or blocking
> anything.
>
> So, the question is:
>
> How does the runtime makes sure that errno is not overwritten by another
> syscall failure? Is it safe to ignore the possibility of another task
> scheduled into the same OS thread?
>
>    - kimhyunkang
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to