1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 7 // * Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // * Redistributions in binary form must reproduce the above 10 // copyright notice, this list of conditions and the following disclaimer 11 // in the documentation and/or other materials provided with the 12 // distribution. 13 // * Neither the name of Google Inc. nor the name Chromium Embedded 14 // Framework nor the names of its contributors may be used to endorse 15 // or promote products derived from this software without specific prior 16 // written permission. 17 // 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=d99ffc2270c1cf8b0f06dd08c1b6e9b27cee4bc8$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_task_capi.h" 44 #include "include/internal/cef_thread_internal.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /// 51 // A simple thread abstraction that establishes a message loop on a new thread. 52 // The consumer uses cef_task_runner_t to execute code on the thread's message 53 // loop. The thread is terminated when the cef_thread_t object is destroyed or 54 // stop() is called. All pending tasks queued on the thread's message loop will 55 // run to completion before the thread is terminated. cef_thread_create() can be 56 // called on any valid CEF thread in either the browser or render process. This 57 // structure should only be used for tasks that require a dedicated thread. In 58 // most cases you can post tasks to an existing CEF thread instead of creating a 59 // new one; see cef_task.h for details. 60 /// 61 typedef struct _cef_thread_t { 62 /// 63 // Base structure. 64 /// 65 cef_base_ref_counted_t base; 66 67 /// 68 // Returns the cef_task_runner_t that will execute code on this thread's 69 // message loop. This function is safe to call from any thread. 70 /// 71 struct _cef_task_runner_t*(CEF_CALLBACK* get_task_runner)( 72 struct _cef_thread_t* self); 73 74 /// 75 // Returns the platform thread ID. It will return the same value after stop() 76 // is called. This function is safe to call from any thread. 77 /// 78 cef_platform_thread_id_t(CEF_CALLBACK* get_platform_thread_id)( 79 struct _cef_thread_t* self); 80 81 /// 82 // Stop and join the thread. This function must be called from the same thread 83 // that called cef_thread_create(). Do not call this function if 84 // cef_thread_create() was called with a |stoppable| value of false (0). 85 /// 86 void(CEF_CALLBACK* stop)(struct _cef_thread_t* self); 87 88 /// 89 // Returns true (1) if the thread is currently running. This function must be 90 // called from the same thread that called cef_thread_create(). 91 /// 92 int(CEF_CALLBACK* is_running)(struct _cef_thread_t* self); 93 } cef_thread_t; 94 95 /// 96 // Create and start a new thread. This function does not block waiting for the 97 // thread to run initialization. |display_name| is the name that will be used to 98 // identify the thread. |priority| is the thread execution priority. 99 // |message_loop_type| indicates the set of asynchronous events that the thread 100 // can process. If |stoppable| is true (1) the thread will stopped and joined on 101 // destruction or when stop() is called; otherwise, the thread cannot be stopped 102 // and will be leaked on shutdown. On Windows the |com_init_mode| value 103 // specifies how COM will be initialized for the thread. If |com_init_mode| is 104 // set to COM_INIT_MODE_STA then |message_loop_type| must be set to ML_TYPE_UI. 105 /// 106 CEF_EXPORT cef_thread_t* cef_thread_create( 107 const cef_string_t* display_name, 108 cef_thread_priority_t priority, 109 cef_message_loop_type_t message_loop_type, 110 int stoppable, 111 cef_com_init_mode_t com_init_mode); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif // CEF_INCLUDE_CAPI_CEF_THREAD_CAPI_H_ 118