1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_INODE_POOL_H_
6 #define LIBRARIES_NACL_IO_INODE_POOL_H_
11 #include "nacl_io/osstat.h"
13 #include "sdk_util/auto_lock.h"
19 INodePool() : num_nodes_(0), max_nodes_(0) {}
23 const int INO_CNT
= 8;
25 // If we run out of INO numbers, then allocate 8 more
26 if (inos_
.size() == 0) {
27 max_nodes_
+= INO_CNT
;
28 // Add eight more to the stack in reverse order, offset by 1
29 // since '0' refers to no INO.
30 for (int a
= 0; a
< INO_CNT
; a
++) {
31 inos_
.push_back(max_nodes_
- a
);
35 // Return the INO at the top of the stack.
36 int val
= inos_
.back();
42 void Release(ino_t ino
) {
48 size_t size() const { return num_nodes_
; }
49 size_t capacity() const { return max_nodes_
; }
54 std::vector
<ino_t
> inos_
;
55 sdk_util::SimpleLock lock_
;
58 } // namespace nacl_io
60 #endif // LIBRARIES_NACL_IO_INODE_POOL_H_