diff options
author | Lukas Larsson <[email protected]> | 2016-02-01 11:01:40 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-03-29 14:57:11 +0200 |
commit | 209c5cf22b5cdc70eb48e6afdcddfa7132471aab (patch) | |
tree | 7995d9164900ec2bba0a864ea78520e0e908ad4f /erts/emulator/beam/erl_nif.c | |
parent | 1bd56e2b5141a3afdca4e854e9b667807bf4e2f3 (diff) | |
download | otp-209c5cf22b5cdc70eb48e6afdcddfa7132471aab.tar.gz otp-209c5cf22b5cdc70eb48e6afdcddfa7132471aab.tar.bz2 otp-209c5cf22b5cdc70eb48e6afdcddfa7132471aab.zip |
erts: Add enif_port_command
Diffstat (limited to 'erts/emulator/beam/erl_nif.c')
-rw-r--r-- | erts/emulator/beam/erl_nif.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_nif.c b/erts/emulator/beam/erl_nif.c index 21bf752bb6..6ed89780b4 100644 --- a/erts/emulator/beam/erl_nif.c +++ b/erts/emulator/beam/erl_nif.c @@ -375,6 +375,29 @@ int enif_send(ErlNifEnv* env, const ErlNifPid* to_pid, return 1; } +int +enif_port_command(ErlNifEnv *env, const ErlNifPort* to_port, + ErlNifEnv *msg_env, ERL_NIF_TERM msg) +{ + + ErtsSchedulerData *esdp = erts_get_scheduler_data(); + int scheduler = esdp ? esdp->no : 0; + Port *prt; + + if (scheduler == 0 || !env) + return 0; + + prt = erts_port_lookup(to_port->port_id, + (erts_port_synchronous_ops + ? ERTS_PORT_SFLGS_INVALID_DRIVER_LOOKUP + : ERTS_PORT_SFLGS_INVALID_LOOKUP)); + + if (!prt) + return 0; + + return erts_port_output_async(prt, env->proc->common.id, msg); +} + ERL_NIF_TERM enif_make_copy(ErlNifEnv* dst_env, ERL_NIF_TERM src_term) { Uint sz; |