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
2482  {
2483  Details::EventSourceInitialize(&__targets);
2484  }
void * __targets
Definition: vccorlib.h:2633
Platform::EventSource::~EventSource ( )
inline
2487  {
2488  Details::EventSourceUninitialize(&__targets);
2489  }
void * __targets
Definition: vccorlib.h:2633

Member Function Documentation

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

Member Data Documentation

void* Platform::EventSource::__targets
protected

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