Beatmup
Beatmup::ContextEventListener Class Reference

Needed for correct functioning of JNI. More...

#include <context_event_listener.h>

Inheritance diagram for Beatmup::ContextEventListener:
Beatmup::Context::EventListener

Public Member Functions

 ContextEventListener (JNIEnv *jenv)
 
void threadCreated (PoolIndex pool)
 Called when a new worker thread is created. More...
 
void threadTerminating (PoolIndex pool)
 Called when a worker thread finished. More...
 
void taskFail (PoolIndex pool, Beatmup::AbstractTask &task, const std::exception &ex)
 Called when a task fails. More...
 
void gpuInitFail (PoolIndex pool, const std::exception &ex)
 Called when GPU initialization failed. More...
 
bool taskDone (PoolIndex pool, Beatmup::AbstractTask &task, bool aborted)
 Called when a task is successfully finished. More...
 
- Public Member Functions inherited from Beatmup::Context::EventListener
virtual ~EventListener ()
 

Private Attributes

JavaVM * jvm
 

Detailed Description

Needed for correct functioning of JNI.

Definition at line 27 of file context_event_listener.h.

Constructor & Destructor Documentation

◆ ContextEventListener()

ContextEventListener::ContextEventListener ( JNIEnv *  jenv)

Definition at line 25 of file context_event_listener.cpp.

25  {
26  jenv->GetJavaVM(&jvm);
27 }
JNIEnv * jenv

Member Function Documentation

◆ threadCreated()

void ContextEventListener::threadCreated ( PoolIndex  pool)
virtual

Called when a new worker thread is created.

Implements Beatmup::Context::EventListener.

Definition at line 30 of file context_event_listener.cpp.

30  {
31  // thread attaching is performed every time it is actually needed
32 }

◆ threadTerminating()

void ContextEventListener::threadTerminating ( PoolIndex  pool)
virtual

Called when a worker thread finished.

Implements Beatmup::Context::EventListener.

Definition at line 35 of file context_event_listener.cpp.

35  {
36  // thread detaching is done here
37  jvm->DetachCurrentThread();
38 }

◆ taskFail()

void ContextEventListener::taskFail ( PoolIndex  pool,
Beatmup::AbstractTask task,
const std::exception &  ex 
)
virtual

Called when a task fails.

Parameters
[in]poolThe thread pool the task was run in
[in]taskThe task
[in]exException caught when the task is failed

Implements Beatmup::Context::EventListener.

Definition at line 41 of file context_event_listener.cpp.

41  {
42  LOG_E("BEATMUP GLOBAL EVENT: TASK FAILED in pool %d", pool);
43 }
#define LOG_E(...)
Definition: log.h:24

◆ gpuInitFail()

void ContextEventListener::gpuInitFail ( PoolIndex  pool,
const std::exception &  ex 
)
virtual

Called when GPU initialization failed.

Parameters
[in]poolThe thread pool the failure occurred in
[in]exException caught

Implements Beatmup::Context::EventListener.

Definition at line 46 of file context_event_listener.cpp.

46  {
47  LOG_E("BEATMUP GLOBAL EVENT: GPU INITIALIZATION FAILED in pool %d", pool);
48 }

◆ taskDone()

bool ContextEventListener::taskDone ( PoolIndex  pool,
Beatmup::AbstractTask task,
bool  aborted 
)
virtual

Called when a task is successfully finished.

Parameters
[in]poolThe thread pool the task was run in
[in]taskThe task
[in]abortedIf true, the task was aborted from outside
Returns
true if the task is asked to be executed again. Note that even if false is returned, a repetition might be asked from outside.

Implements Beatmup::Context::EventListener.

Definition at line 51 of file context_event_listener.cpp.

51  {
52  return false;
53 }

Member Data Documentation

◆ jvm

JavaVM* Beatmup::ContextEventListener::jvm
private

Definition at line 29 of file context_event_listener.h.


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