logo
down
shadow

Are erlang:send_after/3 and timer:send_after/3 intended to behave differently?


Are erlang:send_after/3 and timer:send_after/3 intended to behave differently?

By : Julián Andreoni
Date : October 17 2020, 01:08 AM
Any of those help TL;DR
Your assumption is correct: these are intended to do the same thing, but are implemented differently.
code :
-module(foo_forward).
-export([send_after/3, cancel/1]).
% Obviously this is an example only. You would want to write this to
% be compliant with proc_lib, write a proper init/N and integrate with
% OTP. Note that this snippet is missing the OTP service functions.

start() ->
    spawn(fun() -> loop(self(), [], none) end).

send_after(Time, Dest, Message) ->
    erlang:send_after(Time, self(), {forward, Dest, Message}).

loop(Parent, Debug, State) ->
    receive
        {forward, Dest, Message} ->
            Dest ! Message,
            loop(Parent, Debug, State);
        {system, From, Request} ->
            sys:handle_msg(Request, From, Parent, ?MODULE, Debug, State);
        Unexpected ->
            ok = log(warning, "Received message: ~tp", [Unexpected]),
            loop(Parent, Debug, State)
    end.


Share : facebook icon twitter icon
erlang:start_timer/3 vs timer:send_after/3

erlang:start_timer/3 vs timer:send_after/3


By : DPT
Date : March 29 2020, 07:55 AM
Why are unpack and show defined differently in Data.Text (and behave differently for non-ASCII characters?)

Why are unpack and show defined differently in Data.Text (and behave differently for non-ASCII characters?)


By : Sam Younon
Date : March 29 2020, 07:55 AM
To fix the issue you can do This is a general thing about Show: it's intended rather to produce a kind of preview of objects that can double as a portable serialisation, readable as Haskell code. Obviously, 你好我的朋友 is not valid Haskell (unless you define it as a variable, which you actually can!), so it would not be acceptable as output of show. It would be quite ok if it produced "你好我的朋友" (in fact, I would prefer that), but this might cause Platform etc. problems when you're not throughoutly using full UTF-8 in all of your work chain, so the safer expansion to ASCII was chosen.
If you want the nice non-escaped plain-string output as the GHCi echo, you can use the new custom-pretty-printer feature. I already wrote something about that here.
CSS: Nested span tags behave differently when you type differently?

CSS: Nested span tags behave differently when you type differently?


By : Nimesh Luhana
Date : March 29 2020, 07:55 AM
it should still fix some issue Those 2 blocks of code are the same but when they are output, they look differently. There is a gutter in between each characters on the second one? , Yes, because enter or '\n' is equal to a space in HTML
Erlang timer counter (timer:tc) rounding to nearest 1000?

Erlang timer counter (timer:tc) rounding to nearest 1000?


By : Jasar Nurdynbay
Date : March 29 2020, 07:55 AM
This might help you This is the case on Windows OS (at least XP and 7), but it is rounded to 1000µs, not ms.
Except with very short function it is not a big problem since the execution time varies from one execution to the other.
erlang:send_after message delay

erlang:send_after message delay


By : Tazul
Date : March 29 2020, 07:55 AM
this will help Some clues:
The time you receive is an absolute time and there are many time sources in erlang (see Time and Time Correction in Erlang), so there is a risk to combine the os:system_time with the Erlang Monotonic Time, and you should be aware of the time reference for the TsMsec parameter. In my opinion it should be easier to use relative delay directly in your parameter. The send_after function uses the Erlang Monotonic Time - from the documentation it is not clear if it then works with an absolute or relative time (though I think it is an absolute time). It is said that the Erlang Monitonic Time accuracy depends on Accuracy and precision of OS monotonic time Accuracy and precision of OS system time time warp mode used
Related Posts Related Posts :
shadow
Privacy Policy - Terms - Contact Us © soohba.com