|
Java example source code file (GDIHashtable.h)
The GDIHashtable.h Java example source code/* * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ #ifndef GDIHASHTABLE_H #define GDIHASHTABLE_H #include "Hashtable.h" /* * This class has been created to fix bug #4191297. */ /** * GDIHashtable class. Subclasses Hashtable to provide * capability of batch destruction of freed GDI resources. * Assumes that values are only of AwtGDIObject type. */ class GDIHashtable : public Hashtable { struct ListEntry { GDIHashtable* table; ListEntry* next; }; /** * GDIHashtable::List class. Designed to store pointers * to all existing GDIHashtables. This is required * to flush all GDIHashtables at once. */ class List { public: List() : m_pHead(NULL) {} ~List() { clear(); } void add(GDIHashtable*); void remove(GDIHashtable*); void flushAll(); private: void clear(); ListEntry* m_pHead; CriticalSection m_listLock; }; friend class List; /** * GDIHashtable::BatchDestructionManager class. * Tracks the amount of remaining space in the GDI * and flushes GDIHashtables when needed. */ class BatchDestructionManager { private: int m_nCounter; UINT m_nFirstThreshold; UINT m_nSecondThreshold; UINT m_nDestroyPeriod; BOOL m_bBatchingEnabled; List m_list; CriticalSection m_managerLock; public: /** * Constructs a new BatchDestructionManager with the specified parameters. * The care should be taken when non-default values are used, since it * affects performance. They always should satisfy the inequality * 10 < nSecondThreshold < nFirstThreshold. * * @param nFirstThreshold if less than <code>nFirstThreshold percents * of space in GDI heaps is free all existing GDIHashtables will be * flushed on the next call of <code>update. * @param nSecondThreshold if less than <code>nSecondThreshold * percents of space in GDI heaps is free after the flush * <code>update will return Other Java examples (source code examples)Here is a short list of links related to this Java GDIHashtable.h source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.