Example #1
0
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
   double t = 0.0;

   // inside the thread function lets loop forever incrimenting a time point
   for (;;)
     {
        struct info *inf = malloc(sizeof(struct info));
        int do_exit;

        if (inf)
          {
             inf->x = 200 + (200 * sin(t));
             inf->y = 200 + (200 * cos(t));
             // now call a function in the mainloop and pass it our allocated
             // data that it will free when it gets it
             ecore_main_loop_thread_safe_call_async
                (my_thread_mainloop_code, inf);
          }
        // and sleep and loop
        usleep(1000);
        t += 0.02;
        // in case someone has asked us to cancel - then cancel this loop
        // co-operatively (cancelling is co-operative)
        EnterCriticalSection(&lock);
        do_exit = th_exit;
        LeaveCriticalSection(&lock);
        if (do_exit) break;
     }
   DeleteCriticalSection(&lock);
   return NULL;
}
Example #2
0
// BEGIN - code running in my custom win32 thread instance
//
static DWORD WINAPI
my_thread_run(LPVOID arg)
{
   double t = 0.0;

   // inside the thread function lets loop forever incrimenting a time point
   for (;;)
     {
        struct info *inf = malloc(sizeof(struct info));

        if (inf)
          {
             inf->x = 200 + (200 * sin(t));
             inf->y = 200 + (200 * cos(t));
             // now call a function in the mainloop and pass it our allocated
             // data that it will free when it gets it
             ecore_main_loop_thread_safe_call_async
                (my_thread_mainloop_code, inf);
          }
        // and sleep and loop
        usleep(1000);
        t += 0.02;
     }
   return NULL;
}
bool EcoreCallbackManager::AddEventCallback(Callback callback, int type, EventControl control)
{
  bool added(false);

  if( mRunning )
  {
    CallbackData *callbackData = new CallbackData(callback,CallbackData::EVENT_HANDLER);
    callbackData->mEventControl = control;
    callbackData->mEvent = type;

    callbackData->mRemoveFromContainerFunction =  boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);

    { // acquire lock to access container
      boost::unique_lock< boost::mutex > lock( mMutex );

      // add the call back to the container
      mCallbackContainer.push_front(callbackData);
    }

    // Get callbackData processed on the main loop..
    ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);

    added = true;
  }

  return added;
}
bool EcoreCallbackManager::AddCallback(Callback callback, Priority priority)
{
  bool added(false);

  if ( mRunning )
  {
    CallbackData *callbackData = new CallbackData(callback, CallbackData::STANDARD_CALLBACK);

    callbackData->mPriority = priority;

    callbackData->mRemoveFromContainerFunction =  boost::bind(&EcoreCallbackManager::RemoveCallbackFromContainer, this,_1);

    { // acquire lock to access container
      boost::unique_lock< boost::mutex > lock( mMutex );

      // add the call back to the container
      mCallbackContainer.push_front(callbackData);
    }

    // Get callbackData processed on the main loop..

    ecore_main_loop_thread_safe_call_async(MainLoopCallback, callbackData);

    added = true;
  }

  return added;
}
Example #5
0
static int
EcoreMainLoopCallSync( vout_display_t *vd, mainloop_cb p_cb )
{
    vout_display_sys_t *sys = vd->sys;
    struct mainloop_cb_args args = { .vd = vd, .p_cb = p_cb, .b_signal = false };
    ecore_main_loop_thread_safe_call_async( EcoreMainLoopCb, &args );

    vlc_mutex_lock( &sys->cb_lock );
    while( !args.b_signal )
        vlc_cond_wait( &sys->cb_wait, &sys->cb_lock );
    vlc_mutex_unlock( &sys->cb_lock );

    return args.i_ret;
}

#ifdef HAVE_EVAS_CALLBACK_KEY_UP
static void
EventSendKey( vout_display_t *vd, int i_key )
{
    vout_display_sys_t *sys = vd->sys;
    struct event *p_event = malloc( sizeof(struct event) );

    if( !p_event )
        return;
    p_event->i_type = VOUT_DISPLAY_EVENT_KEY;
    p_event->u.i_key = i_key;
    EVENT_FIFO_PUSH( p_event );
}
Example #6
0
static void
_shutdown(void *data)
{
	prog_t *handle = data;

	handle->client = NULL; // client has died, didn't it?
	ecore_main_loop_thread_safe_call_async(_shutdown_async, handle);
}
Example #7
0
// non-rt
static void
_session(jack_session_event_t *ev, void *data)
{
	prog_t *handle = data;

	handle->session_event = ev;
	ecore_main_loop_thread_safe_call_async(_session_async, data);
}
Example #8
0
static int
_xrun(void *data)
{
	prog_t *handle = data;

	ecore_main_loop_thread_safe_call_async(_xrun_async, handle);

	return 0;
}