equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
63 |
63 |
64 // If there is a lock associated with this buffer, this is that lock. |
64 // If there is a lock associated with this buffer, this is that lock. |
65 Mutex* _lock; |
65 Mutex* _lock; |
66 |
66 |
67 PtrQueueSet* qset() { return _qset; } |
67 PtrQueueSet* qset() { return _qset; } |
|
68 bool is_permanent() const { return _perm; } |
|
69 |
|
70 // Process queue entries and release resources, if not permanent. |
|
71 void flush_impl(); |
68 |
72 |
69 public: |
73 public: |
70 // Initialize this queue to contain a null buffer, and be part of the |
74 // Initialize this queue to contain a null buffer, and be part of the |
71 // given PtrQueueSet. |
75 // given PtrQueueSet. |
72 PtrQueue(PtrQueueSet* qset, bool perm = false, bool active = false); |
76 PtrQueue(PtrQueueSet* qset, bool perm = false, bool active = false); |
73 // Release any contained resources. |
77 |
74 virtual void flush(); |
78 // Requires queue flushed or permanent. |
75 // Calls flush() when destroyed. |
79 ~PtrQueue(); |
76 ~PtrQueue() { flush(); } |
|
77 |
80 |
78 // Associate a lock with a ptr queue. |
81 // Associate a lock with a ptr queue. |
79 void set_lock(Mutex* lock) { _lock = lock; } |
82 void set_lock(Mutex* lock) { _lock = lock; } |
80 |
83 |
81 void reset() { if (_buf != NULL) _index = _sz; } |
84 void reset() { if (_buf != NULL) _index = _sz; } |