OpenMPI  0.1.1
btl_openib_fd.h
1 /*
2  * Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
3  * Copyright (c) 2009 Sandia National Laboratories. All rights reserved.
4  *
5  * $COPYRIGHT$
6  *
7  * Additional copyrights may follow
8  *
9  * $HEADER$
10  */
11 
12 #ifndef OMPI_BTL_OPENIB_FD_H_
13 #define OMPI_BTL_OPENIB_FD_H_
14 
15 #include "ompi_config.h"
16 
17 BEGIN_C_DECLS
18 
19 /**
20  * Typedef for fd callback function
21  */
22 typedef void *(ompi_btl_openib_fd_event_callback_fn_t)(int fd, int flags,
23  void *context);
24 
25 /**
26  * Typedef for generic callback function
27  */
28 typedef void *(ompi_btl_openib_fd_main_callback_fn_t)(void *context);
29 
30 /**
31  * Initialize fd monitoring.
32  * Called by the main thread.
33  */
34 int ompi_btl_openib_fd_init(void);
35 
36 /**
37  * Start monitoring an fd.
38  * Called by main or service thread; callback will be in service thread.
39  */
40 int ompi_btl_openib_fd_monitor(int fd, int flags,
41  ompi_btl_openib_fd_event_callback_fn_t *callback,
42  void *context);
43 
44 /**
45  * Stop monitoring an fd.
46  * Called by main or service thread; callback will be in service thread.
47  */
48 int ompi_btl_openib_fd_unmonitor(int fd,
49  ompi_btl_openib_fd_event_callback_fn_t *callback,
50  void *context);
51 
52 /**
53  * Run a function in the service thread.
54  * Called by the main thread.
55  */
56 int ompi_btl_openib_fd_run_in_service(ompi_btl_openib_fd_main_callback_fn_t callback,
57  void *context);
58 
59 /**
60  * Run a function in the main thread.
61  * Called by the service thread.
62  */
63 int ompi_btl_openib_fd_run_in_main(ompi_btl_openib_fd_main_callback_fn_t callback,
64  void *context);
65 
66 /**
67  * Drain all pending messages from the main thread's pipe.
68  * Likely only useful during finalize, when the event library
69  * won't fire callbacks.
70  */
71 int ompi_btl_openib_fd_main_thread_drain(void);
72 
73 /**
74  * Finalize fd monitoring.
75  * Called by the main thread.
76  */
77 int ompi_btl_openib_fd_finalize(void);
78 
79 END_C_DECLS
80 
81 #endif