Last active
August 29, 2015 14:08
-
-
Save abhijitiitr/9ceba0b519334789dfd6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* niftest.c */ | |
#include "erl_nif.h" | |
#include <unistd.h> | |
#include <stdio.h> | |
static ERL_NIF_TERM hello(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) | |
{ | |
int pid; | |
enif_get_int(env, argv[0], &pid); | |
if (pid==10 || pid==7 || pid == 1) | |
{ | |
printf("%s\n", "Sleeping"); | |
usleep(100); | |
} | |
printf("From %d\n\r",pid); | |
return enif_make_string(env, "Hello world!", ERL_NIF_LATIN1); | |
} | |
static ErlNifFunc nif_funcs[] = | |
{ | |
{"hello", 1, hello} | |
}; | |
ERL_NIF_INIT(niftest,nif_funcs,NULL,NULL,NULL,NULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment