STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
Platform::EventSource Class Reference

#include <vccorlib.h>

Public Member Functions

 EventSource ()
 
 ~EventSource ()
 
::Windows::Foundation::EventRegistrationToken Add (Details::EventLock *__lockArg,::Platform::Object^__delegateInterfaceArg)
 
void Remove (Details::EventLock *__lockArg,::Windows::Foundation::EventRegistrationToken __tokenArg)
 
template<typename __TLambda , typename... __TArgs>
void InvokeVoid (Details::EventLock *__lockArg, __TArgs...__args)
 
template<typename __TLambda , typename __TReturnType , typename... __TArgs>
__TReturnType Invoke (Details::EventLock *__lockArg, __TArgs...__args)
 

Protected Attributes

void__targets
 

Private Member Functions

template<typename __TDelegate , typename __TReturnType , typename __TInvokeMethod >
__TReturnType DoInvoke (Details::EventLock *__lockArg, __TInvokeMethod __invokeOneArg)
 
template<typename __TDelegate , typename __TInvokeMethod >
void DoInvokeVoid (Details::EventLock *__lockArg, __TInvokeMethod __invokeOneArg)
 

Constructor & Destructor Documentation

Platform::EventSource::EventSource ( )
inline
2490  {
2491  Details::EventSourceInitialize(&__targets);
2492  }
void * __targets
Definition: vccorlib.h:2641
Platform::EventSource::~EventSource ( )
inline
2495  {
2496  Details::EventSourceUninitialize(&__targets);
2497  }
void * __targets
Definition: vccorlib.h:2641

Member Function Documentation

::Windows::Foundation::EventRegistrationToken Platform::EventSource::Add ( Details::EventLock __lockArg,
::Platform::Object^  __delegateInterfaceArg 
)
inline
2500  {
2501  return Details::EventSourceAdd(&__targets, __lockArg, reinterpret_cast< ::Platform::Delegate^>(__delegateInterfaceArg));
2502  }
void * __targets
Definition: vccorlib.h:2641
template<typename __TDelegate , typename __TReturnType , typename __TInvokeMethod >
__TReturnType Platform::EventSource::DoInvoke ( Details::EventLock __lockArg,
__TInvokeMethod  __invokeOneArg 
)
inlineprivate
2513  {
2514  // lock pointer exhange
2515  // targets = _targets
2516  // unlock pointer exhange
2517  // iterate all targets and do invoke
2518 
2519  // The _targetsPointerLock protects the acquisition of an AddRef'd pointer to
2520  // "current list". An Add/Remove operation may occur during the
2521  // firing of events (but occurs on a copy of the list). i.e. both
2522  // DoInvoke/invoke and Add/Remove are readers of the "current list".
2523  // NOTE: EventSource::Invoke(...) must never take the _addRemoveLock.
2524  ::Platform::Object^ __targetsLoc;
2525  // Attaching Array without AddRef'ing
2526  *reinterpret_cast<void**>(&__targetsLoc) = Details::EventSourceGetTargetArray(__targets, __lockArg);
2527 
2528  typename __TReturnType __returnVal = typename __TReturnType();
2529  // The list may not exist if nobody has registered
2530  if (__targetsLoc != nullptr)
2531  {
2532  const unsigned int __size = Details::EventSourceGetTargetArraySize(reinterpret_cast<void*>(__targetsLoc));
2533 
2534  for (unsigned int __index = 0; __index < __size; __index++)
2535  {
2536  ::Windows::Foundation::EventRegistrationToken __token = {};
2537 
2538  try
2539  {
2540  __TDelegate^ __element;
2541  *reinterpret_cast<void**>(&__element) = Details::EventSourceGetTargetArrayEvent(
2542  reinterpret_cast<void*>(__targetsLoc),
2543  __index,
2544  reinterpret_cast<const void*>(&__uuidof(__TDelegate^)),
2545  &__token.Value
2546  );
2547 
2548  __returnVal = (__invokeOneArg)(__element);
2549  }
2550  catch(::Platform::Exception^ e)
2551  {
2552  int __hr = e->HResult;
2553  if (__hr == 0x800706BA /* HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) */
2554  || __hr == 0x80010108 /* RPC_E_DISCONNECTED */
2555  || __hr == 0x89020001 /* JSCRIPT_E_CANTEXECUTE */)
2556  {
2557  Details::EventSourceRemove(&__targets, __lockArg, __token);
2558  }
2559  else
2560  {
2561  throw e;
2562  }
2563  }
2564  }
2565  }
2566  return __returnVal;
2567  }
void * __targets
Definition: vccorlib.h:2641
template<typename __TDelegate , typename __TInvokeMethod >
void Platform::EventSource::DoInvokeVoid ( Details::EventLock __lockArg,
__TInvokeMethod  __invokeOneArg 
)
inlineprivate
2573  {
2574  // lock pointer exhange
2575  // targets = _targets
2576  // unlock pointer exhange
2577  // iterate all targets and do invoke
2578 
2579  // The _targetsPointerLock protects the acquisition of an AddRef'd pointer to
2580  // "current list". An Add/Remove operation may occur during the
2581  // firing of events (but occurs on a copy of the list). i.e. both
2582  // Invoke/invoke and Add/Remove are readers of the "current list".
2583  // NOTE: EventSource::Invoke(...) must never take the _addRemoveLock.
2584  ::Platform::Object^ __targetsLoc;
2585  // Attaching Array without AddRef'ing
2586  *reinterpret_cast<void**>(&__targetsLoc) = Details::EventSourceGetTargetArray(__targets, __lockArg);
2587 
2588  // The list may not exist if nobody has registered
2589  if (__targetsLoc != nullptr)
2590  {
2591  const unsigned int __size = Details::EventSourceGetTargetArraySize(reinterpret_cast<void*>(__targetsLoc));
2592 
2593  for (unsigned int __index = 0; __index < __size; __index++)
2594  {
2595  ::Windows::Foundation::EventRegistrationToken __token = {};
2596 
2597  try
2598  {
2599  __TDelegate^ __element;
2600  *reinterpret_cast<void**>(&__element) = Details::EventSourceGetTargetArrayEvent(
2601  reinterpret_cast<void*>(__targetsLoc),
2602  __index,
2603  reinterpret_cast<const void*>(&__uuidof(__TDelegate^)),
2604  &__token.Value
2605  );
2606 
2607  (__invokeOneArg)(__element);
2608  }
2609  catch(::Platform::Exception^ e)
2610  {
2611  int __hr = e->HResult;
2612  if (__hr == 0x800706BA /* HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) */
2613  || __hr == 0x80010108 /* RPC_E_DISCONNECTED */
2614  || __hr == 0x89020001 /* JSCRIPT_E_CANTEXECUTE */)
2615  {
2616  Details::EventSourceRemove(&__targets, __lockArg, __token);
2617  }
2618  else
2619  {
2620  throw e;
2621  }
2622  }
2623  }
2624  }
2625  }
void * __targets
Definition: vccorlib.h:2641
template<typename __TLambda , typename __TReturnType , typename... __TArgs>
__TReturnType Platform::EventSource::Invoke ( Details::EventLock __lockArg,
__TArgs...  __args 
)
inline
2636  {
2637  return DoInvoke<__TLambda, __TReturnType>(__lockArg, [__args...](__TLambda^ __lambda) -> typename __TReturnType { return __lambda(__args...); });
2638  }
template<typename __TLambda , typename... __TArgs>
void Platform::EventSource::InvokeVoid ( Details::EventLock __lockArg,
__TArgs...  __args 
)
inline
2630  {
2631  DoInvokeVoid<__TLambda>(__lockArg, [__args...](__TLambda^ __lambda) -> void { __lambda(__args...); });
2632  }
void Platform::EventSource::Remove ( Details::EventLock __lockArg,
::Windows::Foundation::EventRegistrationToken  __tokenArg 
)
inline
2505  {
2506  Details::EventSourceRemove(&__targets, __lockArg, __tokenArg);
2507  }
void * __targets
Definition: vccorlib.h:2641

Member Data Documentation

void* Platform::EventSource::__targets
protected

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