RejectedSoftware Forums

Sign up

what happened to vibe.core.signal?

hello everyone

i'd like to use https://github.com/eldar/socket.io-d/tree/master/source/socketio but i need to upgrade it to use the latest vibe.d first.

it uses the previous vibe.core.signal module. i see it's replaced but i couldn't find out what it was replaced with. is it vibe.core.sync & ManualEvent or std.signals from phobos?

thanks in advance.

Re: what happened to vibe.core.signal?

Am 02.01.2019 um 10:38 schrieb Mengu:

hello everyone

i'd like to use https://github.com/eldar/socket.io-d/tree/master/source/socketio but i need to upgrade it to use the latest vibe.d first.

it uses the previous vibe.core.signal module. i see it's replaced but i couldn't find out what it was replaced with. is it vibe.core.sync & ManualEvent or std.signals from phobos?

thanks in advance.

The direct equivalent would be vibe.core.sync.LocalManualEvent
(created with createManualEvent). The semantics have changed a bit, so
that the signal.acquire() ... rawYield() ... signal.release() sequence
becomes just signal.wait().

The original code also doesn't use the wait counter, which is necessary
to guarantee race-condition free waiting, so the code should be adjusted
further by doing counter = signal.wait(counter); (counter being an
int initially set to zero), which makes sure that wait doesn't block
if emit has already been called in the meantime.

There are also two alternatives that could also be used for waiting -
InterruptibleTaskCondition (a normal condition variable) and
std.concurrency (message passing). The former is combined with a mutex
and could be used to make the code robust against multiple tasks trying
to send data at the same time.