diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-23 15:49:45 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-04-23 15:49:45 +0000 |
commit | ae1b6b61ce1033cd9ba65667bfc51b4936feaf83 (patch) | |
tree | adde08fc5138ded9a97c78872c72929afeb131e3 /src/core/SkTLS.h | |
parent | 098370137fc9c13acf1631bcc16d9ffbb0abf45f (diff) |
add SkTLS::Delete
git-svn-id: http://skia.googlecode.com/svn/trunk@3752 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core/SkTLS.h')
-rw-r--r-- | src/core/SkTLS.h | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/core/SkTLS.h b/src/core/SkTLS.h index 86886f0080..7368d72854 100644 --- a/src/core/SkTLS.h +++ b/src/core/SkTLS.h @@ -11,19 +11,14 @@ #include "SkTypes.h" +/** + * Maintains a per-thread cache, using a CreateProc as the key into that cache. + */ class SkTLS { public: typedef void* (*CreateProc)(); typedef void (*DeleteProc)(void*); - - /** - * Create proc is called once per thread, and its return value is cached - * and returned by this call, treating the proc as a key. When this thread - * exists, if DeleteProc is not NULL, it is called and passed the value - * that was returned by CreateProc. - */ - static void* Get(CreateProc, DeleteProc); - + /** * If Get() has previously been called with this CreateProc, then this * returns its cached data, otherwise it returns NULL. The CreateProc is @@ -31,6 +26,24 @@ public: * cache. */ static void* Find(CreateProc); + + /** + * Return the cached data that was returned by the CreateProc. This proc + * is only called the first time Get is called, and there after it is + * cached (per-thread), using the CreateProc as a key to look it up. + * + * When this thread, or Delete is called, the cached data is removed, and + * if a DeleteProc was specified, it is passed the pointer to the cached + * data. + */ + static void* Get(CreateProc, DeleteProc); + + /** + * Remove (optionally calling the DeleteProc if it was specificed in Get) + * the cached data associated with this CreateProc. If no associated cached + * data is found, do nothing. + */ + static void Delete(CreateProc); }; #endif |