mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Use std::thread for userevents_multithreaded test (#824)
The genericThread abstraction is not necessary now that C++11 is required.
This commit is contained in:
@@ -16,28 +16,19 @@
|
||||
#include "testBase.h"
|
||||
#include "action_classes.h"
|
||||
#include "harness/conversions.h"
|
||||
#include "harness/genericThread.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
#if !defined (_MSC_VER)
|
||||
#include <unistd.h>
|
||||
#endif // !_MSC_VER
|
||||
|
||||
class releaseEvent_thread : public genericThread
|
||||
void trigger_user_event(cl_event *event)
|
||||
{
|
||||
public:
|
||||
releaseEvent_thread( cl_event *event ) : mEvent( event ) {}
|
||||
|
||||
cl_event * mEvent;
|
||||
|
||||
protected:
|
||||
virtual void * IRun( void )
|
||||
{
|
||||
usleep( 1000000 );
|
||||
log_info( "\tTriggering gate from separate thread...\n" );
|
||||
clSetUserEventStatus( *mEvent, CL_COMPLETE );
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
usleep(1000000);
|
||||
log_info("\tTriggering gate from separate thread...\n");
|
||||
clSetUserEventStatus(*event, CL_COMPLETE);
|
||||
}
|
||||
|
||||
int test_userevents_multithreaded( cl_device_id deviceID, cl_context context, cl_command_queue queue, int num_elements )
|
||||
{
|
||||
@@ -66,14 +57,14 @@ int test_userevents_multithreaded( cl_device_id deviceID, cl_context context, cl
|
||||
}
|
||||
|
||||
// Now, instead of releasing the gate, we spawn a separate thread to do so
|
||||
releaseEvent_thread thread( &gateEvent );
|
||||
log_info( "\tStarting trigger thread...\n" );
|
||||
thread.Start();
|
||||
std::thread thread(trigger_user_event, &gateEvent);
|
||||
|
||||
log_info( "\tWaiting for actions...\n" );
|
||||
error = clWaitForEvents( 3, &actionEvents[ 0 ] );
|
||||
test_error( error, "Unable to wait for action events" );
|
||||
|
||||
thread.join();
|
||||
log_info( "\tActions completed.\n" );
|
||||
|
||||
// If we got here without error, we're good
|
||||
|
||||
Reference in New Issue
Block a user