PTLib
Version 2.14.3
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
id_generator.h
Go to the documentation of this file.
1
/*
2
* handlegen.h
3
*
4
* Class that generates unique numbers in a thread safe manner.
5
*
6
* Portable Tools Library
7
*
8
* Copyright (c) 2013 Vox Lucida
9
*
10
* The contents of this file are subject to the Mozilla Public License
11
* Version 1.0 (the "License"); you may not use this file except in
12
* compliance with the License. You may obtain a copy of the License at
13
* http://www.mozilla.org/MPL/
14
*
15
* Software distributed under the License is distributed on an "AS IS"
16
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
17
* the License for the specific language governing rights and limitations
18
* under the License.
19
*
20
* The Original Code is Portable Windows Library.
21
*
22
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
23
*
24
* Contributor(s): ______________________________________.
25
*
26
* $Revision: 29469 $
27
* $Author: rjongbloed $
28
* $Date$
29
*/
30
31
#ifndef PTLIB_ID_GENERATOR_H
32
#define PTLIB_ID_GENERATOR_H
33
34
#ifdef P_USE_PRAGMA
35
#pragma interface
36
#endif
37
38
#include <set>
39
#include <
ptlib/mutex.h
>
40
41
42
47
class
PIdGenerator
48
{
49
public
:
50
typedef
unsigned
int
Handle
;
51
static
const
Handle
Invalid
;
// Always zero
52
53
private
:
54
Handle
m_nextId;
55
std::set<Handle> m_inUse;
56
PCriticalSection
* m_mutex;
57
58
public
:
59
PIdGenerator
();
60
~PIdGenerator
();
61
62
Handle
Create
();
63
void
Release
(
Handle
id
);
64
bool
IsValid
(
Handle
id
)
const
;
65
};
66
67
68
#endif // PTLIB_ID_GENERATOR_H
69
70
71
// End Of File ///////////////////////////////////////////////////////////////
include
ptlib
id_generator.h
Generated on Fri Oct 10 2014 21:15:13 for PTLib by
1.8.3.1