📄 rwerdlg.h
字号:
// RWerDlg.h : header file
//
#if !defined(AFX_RWERDLG_H__4CDBF419_54FA_4CFC_9FA3_3D999A1200AA__INCLUDED_)
#define AFX_RWERDLG_H__4CDBF419_54FA_4CFC_9FA3_3D999A1200AA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WM_READ_START (WM_USER + 1)//开始读
#define WM_R_WAIT (WM_USER+5)//发送等待者数
#define WM_READ_END (WM_USER + 2)//读完了
#define WM_WRITE_START (WM_USER + 3)//开始写
#define WM_W_WAIT (WM_USER+6)//发送等待者数
#define WM_WRITE_END (WM_USER + 4)//写完了
/////////////////////////////////////////////////////////////////////////////
// CRWerDlg dialog
//struct TEST;
class CRWerDlg;
#define MAX_SIZE 11
struct TEST
{
int index;//线程号
int type;//类型 0为读 1为写
int TStart,TContinu;//开始时间与持续时间
};
struct PARAM//用于传参
{
CRWerDlg* hwnd;
TEST *infor;
};
class CRWerDlg : public CDialog
{
// Construction
public:
LONG ST;//CHU存放时间的秒数
int finish;
void setInit();
void finished();//报告线程完成
int totalThread;//总线程数
int s;//bao保存进入线程的写者数
CMutex listMutex,RcountMutex,writeMutex,S,
WcountMutex;//用于保护s
int Rcount,Rtemp,readTotal,Rwait,Wcount,Wtemp,Wwait,writeTotal;
void addListBox(int type ,int id);
/*listMutex,//控制对列表框的互斥访问
RcountMutex,// 控制对正在工作的读者数的互斥访问
WcountMutex // 控制对等待或已进入线程的写者数的互斥访问
writeMutex,// 控制对读写资源的的互斥访问
S//用于实现写者优先,使得当至少一个写者准备访问共享对象时,他之后的读者线程等待写完成;
*//*CSemaphore * m_pMaxNumSemaphore// 指向新定义的信号量,允许m_Rmax个读者同时访问共享对象m_Rmax的值可指定;
Rcount,// 正在工作的读者数
Rtemp//完成工作任务的读者数,
readTotal,//总读者数
Rwait,//等待的读者数
Wcount,// 正在工作的
Wtemp, //完成工作任务的写者数
Wwait,// 等待的写者数
writeTotal;//总写者数
*/
CWinThread * m_pThread[MAX_SIZE];
CSemaphore * m_pMaxNumSemaphore;
void filetobuffer(CString pathname,TEST buffer[]);
void buffertofile(const TEST buffer[],CString pathname);
CRWerDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CRWerDlg)
enum { IDD = IDD_RWER_DIALOG };
CListBox m_listBox;
CString m_pathName;
int m_write_priority;
int m_Rmax;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRWerDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
void data2text(CString name);
// Generated message map functions
afx_msg LONG ReadStart(UINT wParam,LONG lParam);
afx_msg LONG RWait(UINT wParam,LONG lParam);
afx_msg LONG ReadEnd(UINT wParam,LONG lParam);
afx_msg LONG WriteStart(UINT wParam,LONG lParam);
afx_msg LONG WWait(UINT wParam,LONG lParam);
afx_msg LONG WriteEnd(UINT wParam,LONG lParam);
//{{AFX_MSG(CRWerDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBrowse();
afx_msg void OnCustomize();
afx_msg void OnLoad();
afx_msg void OnStart();
virtual void OnOK();
//afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnClear();
afx_msg void OnSave();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void getRWtotal(int & r,int & w);
};
class CCustomizeDialog : public CDialog
{
// Construction
public:
void viewtobuffer(TEST *buffer,int m_threadCount);
CCustomizeDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCustomizeDialog)
enum { IDD = IDD_DIALOG1 };
CComboBox m_type9;
CComboBox m_type8;
CComboBox m_type7;
CComboBox m_type6;
CComboBox m_type5;
CComboBox m_type4;
CComboBox m_type3;
CComboBox m_type2;
CComboBox m_type10;
CComboBox m_tpye1;
int m_threadCount;
UINT m_start1;
UINT m_start2;
UINT m_start3;
UINT m_start4;
UINT m_start5;
UINT m_start6;
UINT m_start7;
UINT m_start8;
UINT m_start9;
UINT m_start10;
UINT m_continu1;
UINT m_continu2;
UINT m_continu3;
UINT m_continu4;
UINT m_continu5;
UINT m_continu6;
UINT m_continu7;
UINT m_continu8;
UINT m_continu9;
UINT m_continu10;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCustomizeDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CCustomizeDialog)
virtual BOOL OnInitDialog();
afx_msg void OnChangeThreadCount();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnSelchangeCombo1();
virtual void OnOK();
afx_msg void OnKillfocusThreadCount();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
private:
void enableCtrl(int nCount);
void disableCtrl(int nCount);
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_RWERDLG_H__4CDBF419_54FA_4CFC_9FA3_3D999A1200AA__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -