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
2517  {
2518  Details::EventSourceInitialize(&__targets);
2519  }
void * __targets
Definition: vccorlib.h:2668
Platform::EventSource::~EventSource ( )
inline
2522  {
2523  Details::EventSourceUninitialize(&__targets);
2524  }
void * __targets
Definition: vccorlib.h:2668

Member Function Documentation

::Windows::Foundation::EventRegistrationToken Platform::EventSource::Add ( Details::EventLock __lockArg,
::Platform::Object^  __delegateInterfaceArg 
)
inline
2527  {
2528  return Details::EventSourceAdd(&__targets, __lockArg, reinterpret_cast< ::Platform::Delegate^>(__delegateInterfaceArg));
2529  }
void * __targets
Definition: vccorlib.h:2668
template<typename __TDelegate , typename __TReturnType , typename __TInvokeMethod >
__TReturnType Platform::EventSource::DoInvoke ( Details::EventLock __lockArg,
__TInvokeMethod  __invokeOneArg 
)
inlineprivate
2540  {
2541  // lock pointer exhange
2542  // targets = _targets
2543  // unlock pointer exhange
2544  // iterate all targets and do invoke
2545 
2546  // The _targetsPointerLock protects the acquisition of an AddRef'd pointer to
2547  // "current list". An Add/Remove operation may occur during the
2548  // firing of events (but occurs on a copy of the list). i.e. both
2549  // DoInvoke/invoke and Add/Remove are readers of the "current list".
2550  // NOTE: EventSource::Invoke(...) must never take the _addRemoveLock.
2551  ::Platform::Object^ __targetsLoc;
2552  // Attaching Array without AddRef'ing
2553  *reinterpret_cast<void**>(&__targetsLoc) = Details::EventSourceGetTargetArray(__targets, __lockArg);
2554 
2555  typename __TReturnType __returnVal = typename __TReturnType();
2556  // The list may not exist if nobody has registered
2557  if (__targetsLoc != nullptr)
2558  {
2559  const unsigned int __size = Details::EventSourceGetTargetArraySize(reinterpret_cast<void*>(__targetsLoc));
2560 
2561  for (unsigned int __index = 0; __index < __size; __index++)
2562  {
2563  ::Windows::Foundation::EventRegistrationToken __token = {};
2564 
2565  try
2566  {
2567  __TDelegate^ __element;
2568  *reinterpret_cast<void**>(&__element) = Details::EventSourceGetTargetArrayEvent(
2569  reinterpret_cast<void*>(__targetsLoc),
2570  __index,
2571  reinterpret_cast<const void*>(&__uuidof(__TDelegate^)),
2572  &__token.Value
2573  );
2574 
2575  __returnVal = (__invokeOneArg)(__element);
2576  }
2577  catch(::Platform::Exception^ e)
2578  {
2579  int __hr = e->HResult;
2580  if (__hr == 0x800706BA /* HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) */
2581  || __hr == 0x80010108 /* RPC_E_DISCONNECTED */
2582  || __hr == 0x89020001 /* JSCRIPT_E_CANTEXECUTE */)
2583  {
2584  Details::EventSourceRemove(&__targets, __lockArg, __token);
2585  }
2586  else
2587  {
2588  throw e;
2589  }
2590  }
2591  }
2592  }
2593  return __returnVal;
2594  }
void * __targets
Definition: vccorlib.h:2668
template<typename __TDelegate , typename __TInvokeMethod >
void Platform::EventSource::DoInvokeVoid ( Details::EventLock __lockArg,
__TInvokeMethod  __invokeOneArg 
)
inlineprivate
2600  {
2601  // lock pointer exhange
2602  // targets = _targets
2603  // unlock pointer exhange
2604  // iterate all targets and do invoke
2605 
2606  // The _targetsPointerLock protects the acquisition of an AddRef'd pointer to
2607  // "current list". An Add/Remove operation may occur during the
2608  // firing of events (but occurs on a copy of the list). i.e. both
2609  // Invoke/invoke and Add/Remove are readers of the "current list".
2610  // NOTE: EventSource::Invoke(...) must never take the _addRemoveLock.
2611  ::Platform::Object^ __targetsLoc;
2612  // Attaching Array without AddRef'ing
2613  *reinterpret_cast<void**>(&__targetsLoc) = Details::EventSourceGetTargetArray(__targets, __lockArg);
2614 
2615  // The list may not exist if nobody has registered
2616  if (__targetsLoc != nullptr)
2617  {
2618  const unsigned int __size = Details::EventSourceGetTargetArraySize(reinterpret_cast<void*>(__targetsLoc));
2619 
2620  for (unsigned int __index = 0; __index < __size; __index++)
2621  {
2622  ::Windows::Foundation::EventRegistrationToken __token = {};
2623 
2624  try
2625  {
2626  __TDelegate^ __element;
2627  *reinterpret_cast<void**>(&__element) = Details::EventSourceGetTargetArrayEvent(
2628  reinterpret_cast<void*>(__targetsLoc),
2629  __index,
2630  reinterpret_cast<const void*>(&__uuidof(__TDelegate^)),
2631  &__token.Value
2632  );
2633 
2634  (__invokeOneArg)(__element);
2635  }
2636  catch(::Platform::Exception^ e)
2637  {
2638  int __hr = e->HResult;
2639  if (__hr == 0x800706BA /* HRESULT_FROM_WIN32(RPC_S_SERVER_UNAVAILABLE) */
2640  || __hr == 0x80010108 /* RPC_E_DISCONNECTED */
2641  || __hr == 0x89020001 /* JSCRIPT_E_CANTEXECUTE */)
2642  {
2643  Details::EventSourceRemove(&__targets, __lockArg, __token);
2644  }
2645  else
2646  {
2647  throw e;
2648  }
2649  }
2650  }
2651  }
2652  }
void * __targets
Definition: vccorlib.h:2668
template<typename __TLambda , typename __TReturnType , typename... __TArgs>
__TReturnType Platform::EventSource::Invoke ( Details::EventLock __lockArg,
__TArgs...  __args 
)
inline
2663  {
2664  return DoInvoke<__TLambda, __TReturnType>(__lockArg, [__args...](__TLambda^ __lambda) -> typename __TReturnType { return __lambda(__args...); });
2665  }
template<typename __TLambda , typename... __TArgs>
void Platform::EventSource::InvokeVoid ( Details::EventLock __lockArg,
__TArgs...  __args 
)
inline
2657  {
2658  DoInvokeVoid<__TLambda>(__lockArg, [__args...](__TLambda^ __lambda) -> void { __lambda(__args...); });
2659  }
void Platform::EventSource::Remove ( Details::EventLock __lockArg,
::Windows::Foundation::EventRegistrationToken  __tokenArg 
)
inline
2532  {
2533  Details::EventSourceRemove(&__targets, __lockArg, __tokenArg);
2534  }
void * __targets
Definition: vccorlib.h:2668

Member Data Documentation

void* Platform::EventSource::__targets
protected

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