|
Ultralight C++ API 2.0.0
|
#include <Ultralight/platform/Thread.h>
User-defined factory for creating new threads.
You can implement this interface so that the library will use your own implementation for creating threads (useful for tracking thread creation, setting thread names, etc).
The factory covers the threads that run page content: script workers, the JavaScript compiler and garbage collector, networking, and resource loading. The library starts a few threads outside the factory (media playback and some background rendering work), and the libraries it links start their own, so a factory won't account for every thread in the process.
When no factory is defined, the library will create threads using the default platform-specific thread creation functions (eg, _beginthreadex() on Windows, pthread_create() on POSIX).
To provide your own custom ThreadFactory implementation, you should inherit from this class, handle the virtual member functions, and then pass an instance to Platform::set_thread_factory().
Public Member Functions | |
| virtual | ~ThreadFactory ()=default |
| virtual bool | CreateThread (const char *name, ThreadType type, ThreadEntryPoint entry_point, void *entry_point_data, CreateThreadResult &result)=0 |
| Create a new thread. | |
|
virtualdefault |
|
pure virtual |
Create a new thread.
| name | The name of the thread (can be nullptr). |
| type | The type of thread. |
| entry_point | The entry point for the thread. |
| entry_point_data | The data to pass to the entry point. |
| result | The resulting id and handle of the thread creation. |