Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 647589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:44:19+00:00 2026-05-13T21:44:19+00:00

In Erlang is there any way that a message sender can wait on a

  • 0

In Erlang is there any way that a message sender can wait on a response, so it only continues execution once the message has been processed?

And I mean something like this:

Actor ! DoSomething
Continue to this next line of code when DoSomething has been processed

I know a callback can be made by sending the Pid of the sender, but is there any other way to wait?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:44:20+00:00Added an answer on May 13, 2026 at 9:44 pm

    First thing to understand is that Erlang was built to deal with asynchronous message passing. As such, the only way to have synchronous message passing is to implement something akin to an acknowledgement.

    Imagine two processes, P1 and P2. P1 might run the following code:

    %% process P1 takes the Pid of P2 as a parameter
    %% and a Message to pass on to P2
    p1(P2, Message) ->
        P2 ! {self(), Message},
        receive
            {P2, ok}
        after 5000 -> % this section is optional, times out after 5s
            exit("P2 didn't process this!") % this kills P1
        end.
    

    P2, on its side might just run the following:

    p2() ->
        receive
            {From, Message} ->
                io:format("P2 received message ~p~n",[Message]),
                %% processing is done!
                From ! {self(), ok}
        end.
    

    So then you might spawn p2 as a new process. This one will sit waiting for any message. When you then call p1, it sends a message to P2, which then processes it (io:format/2) and replies to P1. Because P1 was waiting for a reply, no additional code was run inside that process.

    That’s the basic and only way to implement blocking calls. The suggestions to use gen_server:call roughly implement what I’ve just shown. It’s hidden from the programmer, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any good code profilers/analyzers for Erlang? I need something that can build
Is there any open-source document-oriented key-value map/reduce storage that: is easily embeddable (Yes, it
There are certain common library functions in erlang that are much slower than their
In the Erlang crypto library, there is no aes_cfb_ivec function. Does it mean that
There's a lot of interest these days in Erlang as a language for writing
The Erlang documentation contains the documentation of modules. Where can I find the documentation
I recently discovered Erlang and am now working my way through a couple of
In RPC semantics where Erlang has hope for the best, SUN RPC with at-least
I have a process in erlang that is supposed to do something immediately after
Erlang with mnesia/dets is famous for it slow startup times after a crash. Basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.