coroutine-rs icon indicating copy to clipboard operation
coroutine-rs copied to clipboard

thread safe documentation

Open edfraenkel opened this issue 8 years ago • 1 comments

The text "Thread-safe: can only resume a coroutine in one thread simultaneously" in the readme.md might scare people away. Is this meant to mean "does not implement send and/or sync yet" or "it is inherently unsafe to use in multiple threads"?

edfraenkel avatar May 05 '17 15:05 edfraenkel

Specifically, it means "does not implement send and sync yet".


let coro = ...;

thread::spawn(|| {
    coro.resume(); // Resume in thread 1
});

thread::spawn(|| {
    coro.resume(); // Resume in thread 2
});

In this example, you resume the coroutine in two different threads simultaneously.

So in the documentation, I was planned to find a way to prevent users to do this.

zonyitoo avatar May 06 '17 12:05 zonyitoo