NewMadeleine

Documentation

« back to PM2 home.
nm_onesided_queues.c
/*
* NewMadeleine
* Copyright (C) 2006-2022 (see AUTHORS file)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include "../common/nm_examples_helper.h"
#include <stdio.h>
static const char*p_msg = "hello world";
int main(int argc, char**argv)
{
const nm_tag_t tag = 0x01;
nm_examples_init(&argc, argv);
/* intialize the onesided interface */
nm_onesided_t p_onesided;
nm_onesided_init(p_session, &p_onesided);
{
nm_sr_send(p_session, p_gate, tag, &q, sizeof(q));
char*p_ptr = NULL;
while(p_ptr == NULL)
{
p_ptr = nm_onesided_queue_dequeue(p_onesided, q);
}
printf("received message: %s\n", p_ptr);
padico_free(p_ptr);
}
else
{
nm_sr_recv(p_session, p_gate, tag, &q, sizeof(q));
printf("received queue id = %d\n", q);
p_msg, strlen(p_msg) + 1, &req);
}
/* stop the onesided interface */
nm_onesided_finalize(p_onesided);
}
void nm_onesided_finalize(nm_onesided_t p_onesided)
void nm_onesided_init(nm_session_t p_session, nm_onesided_t *pp_onesided)
initialize the interface, using the given session.
void nm_onesided_req_wait(nm_onesided_request_t *p_req)
wait for this request completion
int nm_onesided_queue_id_t
local id for a queue
nm_onesided_queue_id_t nm_onesided_queue_create(nm_onesided_t p_onesided)
create a local queue, accessible remotely
void nm_onesided_queue_ienqueue(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, nm_onesided_queue_id_t queue, const void *p_ptr, nm_len_t len, nm_onesided_request_t *p_req)
enqueue a message in the given remote queue, non-blocking version
void * nm_onesided_queue_dequeue(nm_onesided_t p_onesided, nm_onesided_queue_id_t queue)
try to dequeue an entry from local queue; return NULL if queue is empty.
nm_tag_t tag
the user-supplied tag
static int is_server
static void nm_examples_init(int *argc, char *argv[])
static nm_session_t p_session
static void nm_examples_exit(void)
static nm_gate_t p_gate
uint64_t req
a type of debug request; unused for now
Definition nm_headers.h:1
static int nm_sr_recv(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, void *data, nm_len_t len)
blocking recv
static int nm_sr_send(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, const void *data, nm_len_t len)
blocking send
uint64_t nm_tag_t
user tags, 64 bits, contained in indirect hashtable
Definition nm_types.h:56
a send request for onesided
an instance of interface 'onesided'