Posted Mon, 14 Jan 2019 20:34:59 +0100 in reply to Mengu
Am 02.01.2019 um 10:38 schrieb Mengu:
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
createManualEvent). The semantics have changed a bit, so
signal.acquire() ... rawYield() ... signal.release() sequence
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
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.