| OLD | NEW |
| 1 // Copyright 2011 Google Inc. All Rights Reserved. | 1 // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 // | 2 // |
| 3 // This code is licensed under the same terms as WebM: | 3 // This code is licensed under the same terms as WebM: |
| 4 // Software License Agreement: http://www.webmproject.org/license/software/ | 4 // Software License Agreement: http://www.webmproject.org/license/software/ |
| 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ | 5 // Additional IP Rights Grant: http://www.webmproject.org/license/additional/ |
| 6 // ----------------------------------------------------------------------------- | 6 // ----------------------------------------------------------------------------- |
| 7 // | 7 // |
| 8 // Multi-threaded worker | 8 // Multi-threaded worker |
| 9 // | 9 // |
| 10 // Author: Skal (pascal.massimino@gmail.com) | 10 // Author: Skal (pascal.massimino@gmail.com) |
| 11 | 11 |
| 12 #ifndef WEBP_UTILS_THREAD_H_ | 12 #ifndef WEBP_UTILS_THREAD_H_ |
| 13 #define WEBP_UTILS_THREAD_H_ | 13 #define WEBP_UTILS_THREAD_H_ |
| 14 | 14 |
| 15 #ifdef HAVE_CONFIG_H |
| 16 #include "config.h" |
| 17 #endif |
| 18 |
| 15 #if defined(__cplusplus) || defined(c_plusplus) | 19 #if defined(__cplusplus) || defined(c_plusplus) |
| 16 extern "C" { | 20 extern "C" { |
| 17 #endif | 21 #endif |
| 18 | 22 |
| 19 #if WEBP_USE_THREAD | 23 #if WEBP_USE_THREAD |
| 20 | 24 |
| 21 #if defined(_WIN32) | 25 #if defined(_WIN32) |
| 22 | 26 |
| 23 #include <windows.h> | 27 #include <windows.h> |
| 24 typedef HANDLE pthread_t; | 28 typedef HANDLE pthread_t; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 #endif | 60 #endif |
| 57 WebPWorkerStatus status_; | 61 WebPWorkerStatus status_; |
| 58 WebPWorkerHook hook; // hook to call | 62 WebPWorkerHook hook; // hook to call |
| 59 void* data1; // first argument passed to 'hook' | 63 void* data1; // first argument passed to 'hook' |
| 60 void* data2; // second argument passed to 'hook' | 64 void* data2; // second argument passed to 'hook' |
| 61 int had_error; // return value of the last call to 'hook' | 65 int had_error; // return value of the last call to 'hook' |
| 62 } WebPWorker; | 66 } WebPWorker; |
| 63 | 67 |
| 64 // Must be called first, before any other method. | 68 // Must be called first, before any other method. |
| 65 void WebPWorkerInit(WebPWorker* const worker); | 69 void WebPWorkerInit(WebPWorker* const worker); |
| 66 // Must be called initialize the object and spawn the thread. Re-entrant. | 70 // Must be called to initialize the object and spawn the thread. Re-entrant. |
| 67 // Will potentially launch the thread. Returns false in case of error. | 71 // Will potentially launch the thread. Returns false in case of error. |
| 68 int WebPWorkerReset(WebPWorker* const worker); | 72 int WebPWorkerReset(WebPWorker* const worker); |
| 69 // Make sure the previous work is finished. Returns true if worker->had_error | 73 // Makes sure the previous work is finished. Returns true if worker->had_error |
| 70 // was not set and not error condition was triggered by the working thread. | 74 // was not set and no error condition was triggered by the working thread. |
| 71 int WebPWorkerSync(WebPWorker* const worker); | 75 int WebPWorkerSync(WebPWorker* const worker); |
| 72 // Trigger the thread to call hook() with data1 and data2 argument. These | 76 // Triggers the thread to call hook() with data1 and data2 argument. These |
| 73 // hook/data1/data2 can be changed at any time before calling this function, | 77 // hook/data1/data2 can be changed at any time before calling this function, |
| 74 // but not be changed afterward until the next call to WebPWorkerSync(). | 78 // but not be changed afterward until the next call to WebPWorkerSync(). |
| 75 void WebPWorkerLaunch(WebPWorker* const worker); | 79 void WebPWorkerLaunch(WebPWorker* const worker); |
| 76 // Kill the thread and terminate the object. To use the object again, one | 80 // Kill the thread and terminate the object. To use the object again, one |
| 77 // must call WebPWorkerReset() again. | 81 // must call WebPWorkerReset() again. |
| 78 void WebPWorkerEnd(WebPWorker* const worker); | 82 void WebPWorkerEnd(WebPWorker* const worker); |
| 79 | 83 |
| 80 //------------------------------------------------------------------------------ | 84 //------------------------------------------------------------------------------ |
| 81 | 85 |
| 82 #if defined(__cplusplus) || defined(c_plusplus) | 86 #if defined(__cplusplus) || defined(c_plusplus) |
| 83 } // extern "C" | 87 } // extern "C" |
| 84 #endif | 88 #endif |
| 85 | 89 |
| 86 #endif /* WEBP_UTILS_THREAD_H_ */ | 90 #endif /* WEBP_UTILS_THREAD_H_ */ |
| OLD | NEW |