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

📄 wait_queue.h

📁 用c++包装好的线程库,直接拿来使用,提高效率.
💻 H
字号:
#ifndef __THREAD_WAIT_QUEUE_H#define __THREAD_WAIT_QUEUE_H#include "spinlock.h"#include "attributes.h"extern "C" {# include <sys/types.h>};#define __THREAD_QUEUE_MAX    64namespace cpp_threads {  struct priority_queue {    pid_t   q_pid;    int     q_pri;  };  class WaitQueue {  private:    int               _id;    attributes::scope _scope;    struct storage {      int            w_magic;      short          w_top,w_bottom;      spinlock       w_sync;      priority_queue w_pid[__THREAD_QUEUE_MAX];    } *_wq;    void init(attributes::scope);  public:    WaitQueue(int);    WaitQueue(attributes::scope);    WaitQueue();    ~WaitQueue();        bool empty();        void insert(int,int p=-1);    void remove(int);        void suspendMe(int p=-1);    void wakeUp();  };}; // namespace#endif /* __THREAD_WAIT_QUEUE_H */

⌨️ 快捷键说明

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