photon v0.9.0 with Go-style D-flavored channels!
Dmitry Olshansky
dmitry.olsh at gmail.com
Fri May 10 14:30:00 UTC 2024
On Friday, 3 May 2024 at 17:12:40 UTC, Dmitry Olshansky wrote:
> On Monday, 29 April 2024 at 20:50:59 UTC, Dmitry Olshansky
> wrote:
>> On Monday, 29 April 2024 at 20:50:24 UTC, Dmitry Olshansky
>> wrote:
>>> Photon is a minimalistic multi-threaded fiber scheduler and
>>> event loop that works transparently with traditional blocking
>>> I/O C/C++/D/Rust libraries w/o degrading performance.
>>>
>
> And now we have Channels, gentelmen. The only missing bit is
> `select` function to multiplex on a bunch of channels.
And the wait is over! Now there is a select function to multiplex
on read side of a bunch of channels. This also fixes a bug in the
poll syscall override with multiple events on posix systems
https://github.com/DmitryOlshansky/photon/blob/master/examples/select.d
```d
module examples.select;
import std.range, std.datetime, std.stdio;
import photon;
void main() {
startloop();
auto first = channel!(int)(2);
auto second = channel!(string)(1);
go({
delay(500.msecs);
first.put(0);
first.put(1);
delay(500.msecs);
second.put("ping");
});
go({
foreach ( _; 0..3) {
select(
first, {
writefln("Got first %s", first.take(1));
},
second, {
writefln("Got second %s", second.take(1));
}
);
}
});
runFibers();
}
```
> ---
> Dmitry Olshansky
> CEO @ [Glow labs](https://glow-labs.pro)
> https://olshansky.me/about/
More information about the Digitalmars-d-announce
mailing list