Loading...
Searching...
No Matches
ThreadFactoryabstract

#include <Ultralight/platform/Thread.h>

Overview

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).

Default Implementation

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).

Setting the Thread Factory

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.
 

Constructor & Destructor Documentation

◆ ~ThreadFactory()

virtual ~ThreadFactory ( )
virtualdefault

Member Function Documentation

◆ CreateThread()

virtual bool CreateThread ( const char * name,
ThreadType type,
ThreadEntryPoint entry_point,
void * entry_point_data,
CreateThreadResult & result )
pure virtual

Create a new thread.

Parameters
nameThe name of the thread (can be nullptr).
typeThe type of thread.
entry_pointThe entry point for the thread.
entry_point_dataThe data to pass to the entry point.
resultThe resulting id and handle of the thread creation.
Returns
Returns whether or not the thread was created successfully.

The documentation for this class was generated from the following file: