server.c 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * (C) 2015 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <abt.h>
Philip Carns's avatar
Philip Carns committed
11 12
#include <abt-snoozer.h>
#include <margo.h>
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

#include "my-rpc.h"

/* example server program.  Starts HG engine, registers the example RPC type,
 * and then executes indefinitely.
 */

int main(int argc, char **argv) 
{
    int ret;
    ABT_eventual eventual;
    int shutdown;
    
    ret = ABT_init(argc, argv);
    if(ret != 0)
    {
        fprintf(stderr, "Error: ABT_init()\n");
        return(-1);
    }

Philip Carns's avatar
Philip Carns committed
33 34
    /* set primary ES to idle without polling */
    ret = ABT_snoozer_xstream_self_set();
35 36
    if(ret != 0)
    {
Philip Carns's avatar
Philip Carns committed
37
        fprintf(stderr, "Error: ABT_snoozer_xstream_self_set()\n");
38 39 40
        return(-1);
    }

Philip Carns's avatar
Philip Carns committed
41
    margo_init(NA_TRUE, "tcp://localhost:1234");
42 43 44 45 46 47 48 49 50 51 52 53 54 55

    /* register RPC */
    my_rpc_register();

    /* suspend this ULT until someone tells us to shut down */
    ret = ABT_eventual_create(sizeof(shutdown), &eventual);
    if(ret != 0)
    {
        fprintf(stderr, "Error: ABT_eventual_create()\n");
        return(-1);
    }

    ABT_eventual_wait(eventual, (void**)&shutdown);

Philip Carns's avatar
Philip Carns committed
56
    margo_finalize();
57 58 59 60 61
    ABT_finalize();

    return(0);
}