Giter VIP home page Giter VIP logo

async's People

Contributors

slepher avatar

Stargazers

 avatar

Watchers

 avatar  avatar

async's Issues

add async_rpc module for rpc promise call

PromiseRemote is a remote promise with formatted_msg message reply.

-module(remote_module).

-include_lib("erlando/include/do.hrl").

-export([remote_function/0]).

remote_function() ->
    async_m:'>>='(
      async_m:lift_reply(
        do([async_m ||
               async_m:add_message(hello),
               async_m:add_message(world),
               async_m:return(ok)
           ])),
      fun({message, Message}) ->
              async_m:message({formatted_msg, io_lib:format("~p", [Message])});
         (Reply) ->
              async_m:pure_return(Reply)
      end).
PromiseRemote = rpc:call(RemoteNode, remote_module, remote_function, []),
Promise = async_rpc:promise_wait(RemoteNode, PromiseRemote),

or

Promise = async_rpc:promise_call(RemoteNode, RemoteNode, remote_module, remote_function, []),

wait promise:

Callback = 
  fun({message, {formatted_msg, Msg}}) ->
            io:format("~s~n", [Msg]);
        (A) ->
            A
  end,
async_m:wait_t(Promise, #{callback => Callback}).

async_m:map_promises is buggy

Promises = lists:map(fun(N) -> async_m:promise_sleep(1000) end, lists:seq(1, 10)).
async_m:wait(async_m:map_promises(Promises)).

will cost 10 secs, not 1 sec.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.