Make Select a singleton

It's going to manipulate process-global signal state, so multiple
instances do not make sense.
This commit is contained in:
Keegan McAllister
2012-05-04 23:37:07 -04:00
committed by Keith Winstein
parent bb651581a7
commit 768d4ce797
9 changed files with 45 additions and 8 deletions
+16
View File
@@ -33,6 +33,17 @@ static fd_set dummy_fd_set;
/* Convenience wrapper for select(2). */
class Select {
public:
static Select &get_instance( void ) {
// NB: not thread-safe
if ( !instance ) {
instance = new Select;
}
return *instance;
}
private:
static Select *instance;
Select()
: max_fd( -1 )
@@ -47,6 +58,11 @@ public:
FD_ZERO( &error_fds );
}
/* not implemented */
Select( const Select & );
Select &operator=( const Select & );
public:
void add_fd( int fd )
{
if ( fd > max_fd ) {