This source file includes following definitions.
- mca_btl_template_proc_construct
- mca_btl_template_proc_destruct
- mca_btl_template_proc_lookup_opal
- mca_btl_template_proc_create
- mca_btl_template_proc_insert
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 #include "opal_config.h"
  20 
  21 
  22 #include "btl_template.h"
  23 #include "btl_template_proc.h"
  24 
  25 static void mca_btl_template_proc_construct(mca_btl_template_proc_t* proc);
  26 static void mca_btl_template_proc_destruct(mca_btl_template_proc_t* proc);
  27 
  28 OBJ_CLASS_INSTANCE(mca_btl_template_proc_t,
  29         opal_list_item_t, mca_btl_template_proc_construct,
  30         mca_btl_template_proc_destruct);
  31 
  32 void mca_btl_template_proc_construct(mca_btl_template_proc_t* template_proc)
  33 {
  34     template_proc->proc_opal = 0;
  35     template_proc->proc_addr_count = 0;
  36     template_proc->proc_endpoints = 0;
  37     template_proc->proc_endpoint_count = 0;
  38     OBJ_CONSTRUCT(&template_proc->proc_lock, opal_mutex_t);
  39     
  40     OPAL_THREAD_LOCK(&mca_btl_template_component.template_lock);
  41     opal_list_append(&mca_btl_template_component.template_procs, &template_proc->super);
  42     OPAL_THREAD_UNLOCK(&mca_btl_template_component.template_lock);
  43 }
  44 
  45 
  46 
  47 
  48 
  49 void mca_btl_template_proc_destruct(mca_btl_template_proc_t* template_proc)
  50 {
  51     
  52     OPAL_THREAD_LOCK(&mca_btl_template_component.template_lock);
  53     opal_list_remove_item(&mca_btl_template_component.template_procs,
  54                           &template_proc->super);
  55     OPAL_THREAD_UNLOCK(&mca_btl_template_component.template_lock);
  56 
  57     
  58     if(NULL != template_proc->proc_endpoints) {
  59         free(template_proc->proc_endpoints);
  60     }
  61     OBJ_DESTRUCT(&template_proc->proc_lock);
  62 }
  63 
  64 
  65 
  66 
  67 
  68 
  69 static mca_btl_template_proc_t* mca_btl_template_proc_lookup_opal(opal_proc_t* opal_proc)
  70 {
  71     mca_btl_template_proc_t* template_proc;
  72 
  73     OPAL_THREAD_LOCK(&mca_btl_template_component.template_lock);
  74 
  75     for(template_proc = (mca_btl_template_proc_t*)
  76             opal_list_get_first(&mca_btl_template_component.template_procs);
  77             template_proc != (mca_btl_template_proc_t*)
  78             opal_list_get_end(&mca_btl_template_component.template_procs);
  79             template_proc  = (mca_btl_template_proc_t*)opal_list_get_next(template_proc)) {
  80 
  81         if(template_proc->proc_opal == opal_proc) {
  82             OPAL_THREAD_UNLOCK(&mca_btl_template_component.template_lock);
  83             return template_proc;
  84         }
  85 
  86     }
  87 
  88     OPAL_THREAD_UNLOCK(&mca_btl_template_component.template_lock);
  89 
  90     return NULL;
  91 }
  92 
  93 
  94 
  95 
  96 
  97 
  98 
  99 
 100 
 101 mca_btl_template_proc_t* mca_btl_template_proc_create(opal_proc_t* opal_proc)
 102 {
 103     mca_btl_template_proc_t* module_proc = NULL;
 104 
 105     
 106 
 107     module_proc = mca_btl_template_proc_lookup_opal(opal_proc);
 108 
 109     if(module_proc != NULL) {
 110 
 111         
 112         return module_proc;
 113     }
 114 
 115     
 116 
 117 
 118     module_proc = OBJ_NEW(mca_btl_template_proc_t);
 119 
 120     
 121     module_proc->proc_endpoint_count = 0;
 122 
 123     module_proc->proc_opal = opal_proc;
 124 
 125     
 126 
 127     module_proc->proc_addr_count = 1;
 128 
 129     
 130 
 131 
 132 
 133 
 134     module_proc->proc_endpoints = (mca_btl_base_endpoint_t**)
 135         malloc(module_proc->proc_addr_count * sizeof(mca_btl_base_endpoint_t*));
 136 
 137     if(NULL == module_proc->proc_endpoints) {
 138         OBJ_RELEASE(module_proc);
 139         return NULL;
 140     }
 141     return module_proc;
 142 }
 143 
 144 
 145 
 146 
 147 
 148 
 149 
 150 int mca_btl_template_proc_insert(mca_btl_template_proc_t* module_proc,
 151         mca_btl_base_endpoint_t* module_endpoint)
 152 {
 153     
 154     module_endpoint->endpoint_proc = module_proc;
 155     module_proc->proc_endpoints[module_proc->proc_endpoint_count++] = module_endpoint;
 156 
 157     return OPAL_SUCCESS;
 158 }