⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cec_reactive_suppliercontrol.h

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 H
字号:
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file   CEC_Reactive_SupplierControl.h
 *
 *  CEC_Reactive_SupplierControl.h,v 1.17 2003/10/28 18:34:18 bala Exp
 *
 *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
 *
 * More details can be found in:
 *
 * http://doc.ece.uci.edu/~coryan/EC/
 */
//=============================================================================

#ifndef TAO_CEC_REACTIVE_SUPPLIERCONTROL_H
#define TAO_CEC_REACTIVE_SUPPLIERCONTROL_H

#include /**/ "ace/pre.h"

#include "CEC_SupplierControl.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "orbsvcs/ESF/ESF_Worker.h"

#include "tao/ORB.h"

#include "ace/Event_Handler.h"

class TAO_CEC_EventChannel;
class TAO_CEC_Reactive_SupplierControl;

#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
class TAO_CEC_TypedEventChannel;
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */

/**
 * @class TAO_CEC_SupplierControl_Adapter
 *
 * @brief Forwards timeout events to the Reactive SupplierControl
 *
 * The Reactive SupplierControl strategy uses the reactor to
 * periodically wakeup and verify the state of the suppliers
 * registered with the Event Channel.
 */
class TAO_Event_Export TAO_CEC_SupplierControl_Adapter 
  : public ACE_Event_Handler
{
public:
  /// Constructor
  TAO_CEC_SupplierControl_Adapter (TAO_CEC_Reactive_SupplierControl *adaptee);

  // = Documented in ACE_Event_Handler.
  virtual int handle_timeout (const ACE_Time_Value &tv,
                              const void *arg = 0);

private:
  /// The adapted object
  TAO_CEC_Reactive_SupplierControl *adaptee_;
};

/**
 * @class TAO_CEC_Reactive_SupplierControl
 *
 * @brief SupplierControl
 *
 * Defines the interface for the supplier control strategy.
 * This strategy handles misbehaving or failing suppliers.
 * = MEMORY MANAGMENT
 * = LOCKING
 * = TODO
 */
class TAO_Event_Export TAO_CEC_Reactive_SupplierControl 
  : public TAO_CEC_SupplierControl
{
public:
  /// Constructor.  It does not assume ownership of the <event_channel>
  /// parameter.
  TAO_CEC_Reactive_SupplierControl (const ACE_Time_Value &rate,
                                    const ACE_Time_Value &timeout,
                                    TAO_CEC_EventChannel *event_channel,
                                    CORBA::ORB_ptr orb);

  /// Constructor for the typed ec.
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
  TAO_CEC_Reactive_SupplierControl (
      const ACE_Time_Value &rate,
      const ACE_Time_Value &timeout,
      TAO_CEC_TypedEventChannel *typed_event_channel,
      CORBA::ORB_ptr orb
    );
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */

  /// destructor...
  virtual ~TAO_CEC_Reactive_SupplierControl (void);

  /// Receive the timeout from the adapter
  void handle_timeout (const ACE_Time_Value &tv,
                       const void* arg);

  // = Documented in TAO_CEC_SupplierControl
  virtual int activate (void);
  virtual int shutdown (void);
  virtual void supplier_not_exist (TAO_CEC_ProxyPushConsumer *proxy
                                   ACE_ENV_ARG_DECL_NOT_USED);
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
  virtual void supplier_not_exist (TAO_CEC_TypedProxyPushConsumer *proxy
                                   ACE_ENV_ARG_DECL_NOT_USED);
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */
  virtual void supplier_not_exist (TAO_CEC_ProxyPullConsumer *proxy
                                   ACE_ENV_ARG_DECL_NOT_USED);
  virtual void system_exception (TAO_CEC_ProxyPullConsumer *proxy,
                                 CORBA::SystemException &
                                 ACE_ENV_ARG_DECL_NOT_USED);

private:
  /// Check if the suppliers still exists.  It is a helper method for
  /// handle_timeout() to isolate the exceptions.
  void query_suppliers (ACE_ENV_SINGLE_ARG_DECL);

private:
  /// The polling rate
  ACE_Time_Value rate_;

  /// The polling timeout
  ACE_Time_Value timeout_;

  /// The Adapter for the reactor events
  TAO_CEC_SupplierControl_Adapter adapter_;

  /// The event channel
  TAO_CEC_EventChannel *event_channel_;

  /// The typed event channel
#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
  TAO_CEC_TypedEventChannel *typed_event_channel_;
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */

  /// The ORB
  CORBA::ORB_var orb_;

  /// To control the timeout policy in the thread
  CORBA::PolicyCurrent_var policy_current_;

  /// Precomputed policy list to the set timeout.
  CORBA::PolicyList policy_list_;

  /// The ORB reactor
  ACE_Reactor *reactor_;

#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
  /// The timer id
  int timer_id_;
#endif /* TAO_HAS_CORBA_MESSAGING */
};

// ****************************************************************

class TAO_CEC_Ping_Push_Supplier : public TAO_ESF_Worker<TAO_CEC_ProxyPushConsumer>
{
public:
  TAO_CEC_Ping_Push_Supplier (TAO_CEC_SupplierControl *control);

  virtual void work (TAO_CEC_ProxyPushConsumer *consumer
                     ACE_ENV_ARG_DECL);

private:
  TAO_CEC_SupplierControl *control_;
};

// ****************************************************************

#if defined (TAO_HAS_TYPED_EVENT_CHANNEL)
class TAO_CEC_Ping_Typed_Push_Supplier : public TAO_ESF_Worker<TAO_CEC_TypedProxyPushConsumer>
{
public:
  TAO_CEC_Ping_Typed_Push_Supplier (TAO_CEC_SupplierControl *control);

  virtual void work (TAO_CEC_TypedProxyPushConsumer *consumer
                     ACE_ENV_ARG_DECL);

private:
  TAO_CEC_SupplierControl *control_;
};
#endif /* TAO_HAS_TYPED_EVENT_CHANNEL */

// ****************************************************************

class TAO_CEC_Ping_Pull_Supplier : public TAO_ESF_Worker<TAO_CEC_ProxyPullConsumer>
{
public:
  TAO_CEC_Ping_Pull_Supplier (TAO_CEC_SupplierControl *control);

  virtual void work (TAO_CEC_ProxyPullConsumer *consumer
                     ACE_ENV_ARG_DECL);

private:
  TAO_CEC_SupplierControl *control_;
};

#if defined (__ACE_INLINE__)
#include "CEC_Reactive_SupplierControl.i"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"

#endif /* TAO_CEC_SUPPLIERCONTROL_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -