plptools
Loading...
Searching...
No Matches
iowatch.h
Go to the documentation of this file.
1
/*
2
* This file is part of plptools.
3
*
4
* Copyright (C) 1999 Philip Proudman <philip.proudman@btinternet.com>
5
* Copyright (C) 1999-2001 Fritz Elfert <felfert@to.com>
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License along
18
* along with this program; if not, see <https://www.gnu.org/licenses/>.
19
*
20
*/
21
#pragma once
22
23
#include <mutex>
24
34
class
IOWatch
{
35
public
:
39
IOWatch
();
40
44
~IOWatch
();
45
52
void
addIO
(
const
int
fd);
53
60
void
remIO
(
const
int
fd);
61
70
bool
watch
(
const
long
secs,
const
long
usecs);
71
72
private
:
73
std::mutex
lock_
;
74
int
fileDescriptorCount_
;
75
int
*
fileDescriptors_
;
76
};
IOWatch
A simple thread-safe wrapper for select()
Definition:
iowatch.h:34
IOWatch::fileDescriptorCount_
int fileDescriptorCount_
Definition:
iowatch.h:74
IOWatch::IOWatch
IOWatch()
Creates a new instance.
Definition:
iowatch.cc:32
IOWatch::lock_
std::mutex lock_
Definition:
iowatch.h:73
IOWatch::remIO
void remIO(const int fd)
Removes a file descriptor from the set of descriptors.
Definition:
iowatch.cc:54
IOWatch::addIO
void addIO(const int fd)
Adds a file descriptor to the set of descriptors.
Definition:
iowatch.cc:42
IOWatch::watch
bool watch(const long secs, const long usecs)
Performs a select() call.
Definition:
iowatch.cc:64
IOWatch::~IOWatch
~IOWatch()
Destroys an instance.
Definition:
iowatch.cc:38
IOWatch::fileDescriptors_
int * fileDescriptors_
Definition:
iowatch.h:75
lib
iowatch.h
Generated by
1.9.5