|
Last change
on this file since 1069 was 1016, checked in by ansari, 25 years ago |
|
Creation du module JThreadsC++, importation du code des classes
de Thread a la Java de Object Oriented Concepts Inc - Reza 19/5/2000
|
|
File size:
1.3 KB
|
| Rev | Line | |
|---|
| [1016] | 1 | // **********************************************************************
|
|---|
| 2 | //
|
|---|
| 3 | // Copyright (c) 2000
|
|---|
| 4 | // Object Oriented Concepts, Inc.
|
|---|
| 5 | // Billerica, MA, USA
|
|---|
| 6 | //
|
|---|
| 7 | // All Rights Reserved
|
|---|
| 8 | //
|
|---|
| 9 | // **********************************************************************
|
|---|
| 10 |
|
|---|
| 11 | #ifndef JTC_TSS_MANAGER_H
|
|---|
| 12 | #define JTC_TSS_MANAGER_H
|
|---|
| 13 |
|
|---|
| 14 | //
|
|---|
| 15 | // This class is needed under WIN32 since there are no native support
|
|---|
| 16 | // for thread specific data cleanup. Although POSIX threads have
|
|---|
| 17 | // support for associating destructor functions with a thread key they
|
|---|
| 18 | // cannot be used. This is because the destructor functions have to
|
|---|
| 19 | // run before the thread terminates since any thread joins will occur
|
|---|
| 20 | // before the thread terminates.
|
|---|
| 21 | //
|
|---|
| 22 | class JTCTSSManager
|
|---|
| 23 | {
|
|---|
| 24 | struct KeyCleanup
|
|---|
| 25 | {
|
|---|
| 26 | JTCThreadKey key;
|
|---|
| 27 | void (*release)(void*);
|
|---|
| 28 |
|
|---|
| 29 | KeyCleanup* next;
|
|---|
| 30 | };
|
|---|
| 31 |
|
|---|
| 32 | KeyCleanup* head_; // Head of the cleanup queue
|
|---|
| 33 | JTCMutex mut_;
|
|---|
| 34 |
|
|---|
| 35 | static JTCTSSManager* instance_;
|
|---|
| 36 |
|
|---|
| 37 | public:
|
|---|
| 38 |
|
|---|
| 39 | JTCTSSManager();
|
|---|
| 40 | ~JTCTSSManager();
|
|---|
| 41 |
|
|---|
| 42 | //
|
|---|
| 43 | // Get the singleton
|
|---|
| 44 | //
|
|---|
| 45 | static JTCTSSManager* instance();
|
|---|
| 46 |
|
|---|
| 47 | //
|
|---|
| 48 | // Associate a key and a cleanup function
|
|---|
| 49 | //
|
|---|
| 50 | void allocate(JTCThreadKey key, void(*)(void*));
|
|---|
| 51 |
|
|---|
| 52 | //
|
|---|
| 53 | // Remove the key from our internal table
|
|---|
| 54 | void release(JTCThreadKey);
|
|---|
| 55 |
|
|---|
| 56 | //
|
|---|
| 57 | // Run the cleanup functions
|
|---|
| 58 | //
|
|---|
| 59 | void cleanup();
|
|---|
| 60 | };
|
|---|
| 61 | #endif
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.