| OLD | NEW |
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 #ifndef LIBRARIES_NACL_IO_INODE_POOL_H_ | 6 #ifndef LIBRARIES_NACL_IO_INODE_POOL_H_ |
| 7 #define LIBRARIES_NACL_IO_INODE_POOL_H_ | 7 #define LIBRARIES_NACL_IO_INODE_POOL_H_ |
| 8 | 8 |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "nacl_io/osstat.h" | 12 #include "nacl_io/osstat.h" |
| 13 #include "pthread.h" | 13 #include "pthread.h" |
| 14 #include "sdk_util/auto_lock.h" | 14 #include "sdk_util/auto_lock.h" |
| 15 | 15 |
| 16 namespace nacl_io { |
| 16 | 17 |
| 17 class INodePool { | 18 class INodePool { |
| 18 public: | 19 public: |
| 19 INodePool() : max_nodes_(0), num_nodes_(0) {} | 20 INodePool() : max_nodes_(0), num_nodes_(0) {} |
| 20 | 21 |
| 21 ino_t Acquire() { | 22 ino_t Acquire() { |
| 22 AUTO_LOCK(lock_); | 23 AUTO_LOCK(lock_); |
| 23 const int INO_CNT = 8; | 24 const int INO_CNT = 8; |
| 24 | 25 |
| 25 // If we run out of INO numbers, then allocate 8 more | 26 // If we run out of INO numbers, then allocate 8 more |
| (...skipping 19 matching lines...) Expand all Loading... |
| 45 num_nodes_--; | 46 num_nodes_--; |
| 46 } | 47 } |
| 47 | 48 |
| 48 size_t size() const { return num_nodes_; } | 49 size_t size() const { return num_nodes_; } |
| 49 size_t capacity() const { return max_nodes_; } | 50 size_t capacity() const { return max_nodes_; } |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 size_t num_nodes_; | 53 size_t num_nodes_; |
| 53 size_t max_nodes_; | 54 size_t max_nodes_; |
| 54 std::vector<ino_t> inos_; | 55 std::vector<ino_t> inos_; |
| 55 SimpleLock lock_; | 56 sdk_util::SimpleLock lock_; |
| 56 }; | 57 }; |
| 57 | 58 |
| 59 } // namespace nacl_io |
| 60 |
| 58 #endif // LIBRARIES_NACL_IO_INODE_POOL_H_ | 61 #endif // LIBRARIES_NACL_IO_INODE_POOL_H_ |
| OLD | NEW |