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

📄 task.h

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 H
字号:
// Task.h,v 1.4 2001/12/24 20:51:02 schmidt Exp

// Task.h
//
// Tutorial regarding a way to use ACE_Stream.
//
// written by bob mcwhirter (bob@netwrench.com)

#ifndef TASK_H
#define TASK_H

#include <ace/Task.h>
#include <ace/Synch.h>

// Always typedef when possible.

typedef ACE_Task<ACE_MT_SYNCH> Task_Base;

class Task : public Task_Base
{
public:
  typedef Task_Base inherited;
  // This is just good form.

  Task (const char *nameOfTask,
        int numberOfThreads);
  // Initialize our Task with a name, and number of threads to spawn.

  virtual ~Task (void);

  virtual int open (void *arg);
  // This is provided to prevent compiler complaints about hidden
  // virtual functions.

  virtual int close (u_long flags);
  // This closes down the Task and all service threads.

  virtual int put (ACE_Message_Block *message,
                   ACE_Time_Value *timeout);
  // This is the interface that ACE_Stream uses to communicate with
  // our Task.

  virtual int svc (void);
  // This is the actual service loop each of the service threads
  // iterates through.

  const char *nameOfTask (void) const;
  // Returns the name of this Task.

  static ACE_Lock_Adapter<ACE_SYNCH_MUTEX> *lock_adapter (void);
  // Returns a pointer to the lock adapter.

private:
  int d_numberOfThreads;
  char d_nameOfTask[64];

  ACE_Barrier d_barrier;
  // Simple Barrier to make sure all of our service threads have
  // entered their loop before accepting any messages.

  static ACE_Lock_Adapter<ACE_SYNCH_MUTEX> lock_adapter_;
  // This Lock_Adapter is used to synchronize operations
  // on the ACE_Message_Block objects
};

#endif /* TASK_H */

⌨️ 快捷键说明

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