Ignore:
Timestamp:
11/28/16 14:02:54 (8 years ago)
Author:
rlacroix
Message:

The workflow is now triggered when using xios_recv_field for fields in read mode received from the servers.

Previously the workflow was triggered upon receiving the data which could cause deadlocks since there are no garanties that clients are receiving data at the same time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/filter/input_pin.cpp

    r639 r1006  
    11#include "input_pin.hpp" 
     2#include "output_pin.hpp" 
    23#include "garbage_collector.hpp" 
    34#include "exception.hpp" 
     
    89    : gc(gc) 
    910    , slotsCount(slotsCount) 
     11    , triggers(slotsCount) 
     12    , hasTriggers(false) 
    1013  { /* Nothing to do */ } 
    1114 
     
    2326    { 
    2427      it = inputs.insert(std::make_pair(packet->timestamp, InputBuffer(slotsCount))).first; 
    25       gc.registerFilter(this, packet->timestamp); 
     28      gc.registerObject(this, packet->timestamp); 
    2629    } 
    2730    it->second.slotsFilled++; 
     
    3134    { 
    3235      // Unregister before calling onInputReady in case the filter registers again 
    33       gc.unregisterFilter(this, packet->timestamp); 
     36      gc.unregisterObject(this, packet->timestamp); 
    3437      onInputReady(it->second.packets); 
    3538      inputs.erase(it); 
    3639    } 
     40  } 
     41 
     42  void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger) 
     43  { 
     44    if (inputSlot >= slotsCount) 
     45      ERROR("void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger)", 
     46            "The input slot " << inputSlot << " does not exist."); 
     47    if (triggers[inputSlot]) 
     48      ERROR("void CInputPin::setInputTrigger(size_t inputSlot, COutputPin* trigger)", 
     49            "The trigger for input slot " << inputSlot << " has already been set."); 
     50 
     51    triggers[inputSlot] = trigger; 
     52    hasTriggers = true; 
     53  } 
     54 
     55  void CInputPin::trigger(Time timestamp) 
     56  { 
     57    if (hasTriggers) // Don't use canBeTriggered here, this function is virtual and can be overriden 
     58    { 
     59      std::map<Time, InputBuffer>::iterator it = inputs.find(timestamp); 
     60      bool nothingReceived = (it == inputs.end()); 
     61 
     62      for (size_t s = 0; s < slotsCount; s++) 
     63      { 
     64        if (triggers[s] && (nothingReceived || !it->second.packets[s])) 
     65          triggers[s]->trigger(timestamp); 
     66      } 
     67    } 
     68  } 
     69 
     70  bool CInputPin::canBeTriggered() const 
     71  { 
     72    return hasTriggers; 
    3773  } 
    3874 
Note: See TracChangeset for help on using the changeset viewer.