File: MaskSet.h

package info (click to toggle)
libassa 3.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 3,084 kB
  • ctags: 2,323
  • sloc: cpp: 15,641; sh: 8,704; makefile: 372; perl: 51
file content (91 lines) | stat: -rw-r--r-- 1,917 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// -*- c++ -*-
//------------------------------------------------------------------------------
//                               MaskSet.h
//------------------------------------------------------------------------------
//  Copyright (c) 1999 by Vladislav Grinchenko
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either
//  version 2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef MASK_SET_H
#define MASK_SET_H

#include "assa/FdSet.h"

namespace ASSA {

/** @file MaskSet.h

Bundles file descriptor mask sets to be used with ::select().
*/

class MaskSet
{
public:
	/// Read fds set
	FdSet m_rset;
		
	/// Write fds set
	FdSet m_wset;

	/// Exception fds set
	FdSet m_eset;

public:
	/// Clear all bits in all sets.
	void reset ();

	/// Resync internals after select() call.
	void sync ();

	/// Return maximum value of the file descriptor in the Set
	int  max_fd ();

	/// Write current state of MaskSet object to log file. 
	void dump ();
};

inline void 
MaskSet::
sync () 
{
	m_rset.sync ();
	m_wset.sync ();
	m_eset.sync ();
}


inline void 
MaskSet::
reset () 
{
	m_rset.reset ();
	m_wset.reset ();
	m_eset.reset ();
}

inline int
MaskSet::
max_fd ()
{
	return (std::max (m_rset.maxInSet (), 
					  std::max (m_wset.maxInSet (), 
								m_eset.maxInSet ())));
}

inline void 
MaskSet::
dump () 
{
	DL((REACTTRACE,"+---------------------------\n"));
	DL((REACTTRACE,"| RD FDs set %s\n", m_rset.dump_c_str ().c_str ()));
	DL((REACTTRACE,"| WR FDs set %s\n", m_wset.dump_c_str ().c_str ()));
	DL((REACTTRACE,"| EX FDs set %s\n", m_eset.dump_c_str ().c_str ()));
	DL((REACTTRACE,"+---------------------------\n"));
}

} // end namespace ASSA

#endif /* MASK_SET_H */