AudioManager  7.5.11
Native Application Runtime Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CAmSerializer.h
Go to the documentation of this file.
1 
18 #ifndef CAMSERIALIZER_H_
19 #define CAMSERIALIZER_H_
20 
21 #include <pthread.h>
22 #include <deque>
23 #include <cassert>
24 #include <memory>
25 #include <stdexcept>
26 #include <unistd.h>
27 #include "CAmDltWrapper.h"
28 #include "CAmSocketHandler.h"
29 
35 namespace am
36 {
50 {
51 private:
52 
56  class CAmDelegate
57  {
58  public:
59 
60  typedef enum:bool {
61  SyncCallType = false,
62  AsyncCallType = true
63  } CallType;
64 
65  virtual ~CAmDelegate()
66  {};
67  virtual CallType call(int* pipe)=0;
68 
69  };
70 
74  template <class Class, typename Method, typename Tuple, bool Done, int Total, int... N>
75  class CAmDelegateAsyncImpl : public CAmDelegate
76  {
77  Class mInstance;
78  Method mMethod;
79  Tuple mArguments;
80  public:
81  friend class CAmSerializer;
82  static void call(Class instance, Method method, Tuple && arguments)
83  {
84  CAmDelegateAsyncImpl<Class, Method, Tuple, Total == 1 + sizeof...(N), Total, N..., sizeof...(N)>::call(instance, method, std::forward<Tuple>(arguments));
85  }
86 
87  CAmDelegateAsyncImpl(Class instance, Method method, Tuple && arguments)
88  {
89  mInstance = instance;
90  mMethod = method;
91  mArguments = std::move(arguments);
92  }
93 
94  CallType call(int* pipe)
95  {
96  (void) pipe;
97  call(mInstance, mMethod, std::forward<Tuple>(mArguments));
98  return (AsyncCallType);
99  };
100  };
101 
105  template <class Class, typename Method, typename Tuple, int Total, int... N>
106  class CAmDelegateAsyncImpl<Class, Method, Tuple, true, Total, N...> : public CAmDelegate
107  {
108  Class mInstance;
109  Method mMethod;
110  Tuple mArguments;
111  public:
112  friend class CAmSerializer;
113  static void call(Class instance, Method method, Tuple && t)
114  {
115  (*instance.*method)(std::get<N>(std::forward<Tuple>(t))...);
116  }
117 
118  CAmDelegateAsyncImpl(Class instance, Method method, Tuple && arguments)
119  {
120  mInstance = instance;
121  mMethod = method;
122  mArguments = std::move(arguments);
123  }
124 
125  CallType call(int* pipe)
126  {
127  (void) pipe;
128  call(mInstance, mMethod, std::forward<Tuple>(mArguments));
129  return (AsyncCallType);
130  };
131  };
132 
136  template <class Class, typename Method, typename Return, typename Tuple, bool Done, int Total, int... N>
137  class CAmDelegateSyncImpl : public CAmDelegate
138  {
139  Class mInstance;
140  Method mMethod;
141  Tuple mArguments;
142  Return mReturn;
143  public:
144  friend class CAmSerializer;
145  static void call(Class instance,Method method, Return & result, Tuple && arguments)
146  {
147  CAmDelegateSyncImpl<Class, Method, Return, Tuple, Total == 1 + sizeof...(N), Total, N..., sizeof...(N)>::call(instance, method, result, std::forward<Tuple>(arguments));
148  }
149 
150  CAmDelegateSyncImpl(Class instance, Method method, Tuple && arguments)
151  {
152  mInstance = instance;
153  mMethod = method;
154  mArguments = std::move(arguments);
155  }
156 
157  CallType call(int* pipe)
158  {
159  call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
160  ssize_t result(-1);
161  result = write(pipe[1], this, sizeof(this));
162  if (result == -1)
163  logError("CAmSerializer: Problem writing into pipe! Error No:",errno);
164  return (SyncCallType);
165  };
166  };
167 
171  template <class Class, typename Method, typename Return, typename Tuple, int Total, int... N>
172  class CAmDelegateSyncImpl<Class, Method, Return, Tuple, true, Total, N...> : public CAmDelegate
173  {
174  Class mInstance;
175  Method mMethod;
176  Tuple mArguments;
177  Return mReturn;
178  public:
179  friend class CAmSerializer;
180  static void call(Class instance, Method method, Return & result, Tuple && t)
181  {
182  result = (*instance.*method)(std::get<N>(t)...);
183  }
184 
185  CAmDelegateSyncImpl(Class instance, Method method, Tuple && arguments)
186  {
187  mInstance = instance;
188  mMethod = method;
189  mArguments = std::move(arguments);
190  }
191 
192  CallType call(int* pipe)
193  {
194  call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
195  ssize_t result(-1);
196  result = write(pipe[1], this, sizeof(this));
197  if (result == -1)
198  logError("CAmSerializer: Problem writing into pipe! Error No:",errno);
199  return (SyncCallType);
200  };
201  };
202 
203  typedef CAmDelegate* CAmDelegagePtr;
204 
205 public:
209  template <typename Class, typename Method, typename Tuple>
210  void doAsyncCall(Class intsance, Method method, Tuple & arguments)
211  {
212  typedef typename std::decay<Tuple>::type ttype;
213  typedef CAmDelegateAsyncImpl<Class, Method, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> AsyncDelegate;
214  AsyncDelegate *pImp = new AsyncDelegate(intsance, method, std::forward<Tuple>(arguments));
215  send(pImp);
216  //Do not delete the pointer. It will be deleted automatically later.
217  }
218 
222  template <typename Class, typename Method, typename Return, typename Tuple>
223  void doSyncCall(Class intsance, Method method, Return & result, Tuple & arguments)
224  {
225  typedef typename std::decay<Tuple>::type ttype;
226  typedef CAmDelegateSyncImpl<Class, Method, Return, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> SyncDelegate;
227  SyncDelegate *pImp = new SyncDelegate(intsance, method, std::forward<Tuple>(arguments));
228  send(pImp);
229  int numReads;
230  SyncDelegate *p = NULL;
231  if ((numReads = read(mReturnPipe[0], &p, sizeof(p))) == -1)
232  {
233  logError("CAmSerializer::doSyncCall could not read pipe!");
234  throw std::runtime_error("CAmSerializer Could not read pipe!");
235  }
236  result = std::move(pImp->mReturn);
237  arguments = std::move(pImp->mArguments);
238  //Delete the pointer.
239  delete pImp;
240  }
241 private:
242 
247  inline void send(CAmDelegagePtr p)
248  {
249  if (write(mPipe[1], &p, sizeof(p)) == -1)
250  {
251  throw std::runtime_error("could not write to pipe !");
252  }
253  }
254 
255  int mPipe[2];
256  int mReturnPipe[2];
257  std::deque<CAmDelegagePtr> mListDelegatePoiters;
258 
259 public:
260 
265  {
266  return mListDelegatePoiters.size();
267  }
268 
290  template<class TClass, class TRet, class ... TArgs>
291  void syncCall(TClass* instance, TRet (TClass::*method)(TArgs ...), TRet & result, TArgs & ... arguments)
292  {
293  auto t = std::make_tuple(arguments...);
294  doSyncCall(instance, method, result, t);
295  std::tie(arguments...) = t;
296  }
297 
317  template<class TClass, class TRet, class ... TArgs>
318  void asyncCall(TClass* instance, TRet (TClass::*method)(TArgs ...), TArgs & ... arguments)
319  {
320  auto t = std::make_tuple(arguments...);
321  doAsyncCall(instance, method, t);
322  }
323 
341  template<class TClass>
342  void asyncCall(TClass* instance, void (TClass::*function)())
343  {
344  auto t = std::make_tuple();
345  doAsyncCall(instance, function, t);
346  }
347 
368  template<class TClass1, class Targ>
369  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ), Targ argument)
370  {
371  auto t = std::make_tuple(argument);
372  doAsyncCall(instance, function, t);
373  }
374 
395  template<class TClass1, class Targ>
396  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ&), Targ& argument)
397  {
398  auto t = std::make_tuple(argument);
399  doAsyncCall(instance, function, t);
400  }
401 
412  template<class TClass1, class Targ, class Targ1>
413  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1), Targ argument, Targ1 argument1)
414  {
415  auto t = std::make_tuple(argument,argument1);
416  doAsyncCall(instance, function, t);
417  }
418 
429  template<class TClass1, class Targ, class Targ1>
430  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1), Targ& argument, Targ1 argument1)
431  {
432  auto t = std::make_tuple(argument,argument1);
433  doAsyncCall(instance, function, t);
434  }
435 
446  template<class TClass1, class Targ, class Targ1>
447  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1), Targ argument, Targ1& argument1)
448  {
449  auto t = std::make_tuple(argument,argument1);
450  doAsyncCall(instance, function, t);
451  }
452 
463  template<class TClass1, class Targ, class Targ1>
464  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1), Targ& argument, Targ1& argument1)
465  {
466  auto t = std::make_tuple(argument,argument1);
467  doAsyncCall(instance, function, t);
468  }
469 
473  template<class TClass1, class Targ, class Targ1, class Targ2>
474  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2), Targ argument, Targ1 argument1, Targ2 argument2)
475  {
476  auto t = std::make_tuple(argument,argument1, argument2);
477  doAsyncCall(instance, function, t);
478  }
479 
483  template<class TClass1, class Targ, class Targ1, class Targ2>
484  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2 argument2), Targ& argument, Targ1 argument1, Targ2 argument2)
485  {
486  auto t = std::make_tuple(argument,argument1, argument2);
487  doAsyncCall(instance, function, t);
488  }
489 
490 
494  template<class TClass1, class Targ, class Targ1, class Targ2>
495  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2 argument2), Targ argument, Targ1& argument1, Targ2 argument2)
496  {
497  auto t = std::make_tuple(argument,argument1, argument2);
498  doAsyncCall(instance, function, t);
499  }
500 
504  template<class TClass1, class Targ, class Targ1, class Targ2>
505  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2& argument2), Targ argument, Targ1 argument1, Targ2& argument2)
506  {
507  auto t = std::make_tuple(argument,argument1, argument2);
508  doAsyncCall(instance, function, t);
509  }
510 
514  template<class TClass1, class Targ, class Targ1, class Targ2>
515  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2& argument2), Targ argument, Targ1& argument1, Targ2& argument2)
516  {
517  auto t = std::make_tuple(argument,argument1, argument2);
518  doAsyncCall(instance, function, t);
519  }
520 
524  template<class TClass1, class Targ, class Targ1, class Targ2>
525  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2& argument2), Targ& argument, Targ1& argument1, Targ2& argument2)
526  {
527  auto t = std::make_tuple(argument,argument1, argument2);
528  doAsyncCall(instance, function, t);
529  }
530 
534  template<class TClass1, class Targ, class Targ1, class Targ2>
535  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2 argument2), Targ& argument, Targ1& argument1, Targ2 argument2)
536  {
537  auto t = std::make_tuple(argument,argument1, argument2);
538  doAsyncCall(instance, function, t);
539  }
540 
544  template<class TClass1, class Targ, class Targ1, class Targ2>
545  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2& argument2), Targ& argument, Targ1 argument1, Targ2& argument2)
546  {
547  auto t = std::make_tuple(argument,argument1, argument2);
548  doAsyncCall(instance, function, t);
549  }
550 
554  template<class TClass1, class Targ, class Targ1, class Targ2, class Targ3>
555  void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3), Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3)
556  {
557  auto t = std::make_tuple(argument,argument1, argument2,argument3);
558  doAsyncCall(instance, function, t);
559  }
560 
583  template<class TClass1, class TretVal>
584  void syncCall(TClass1* instance, TretVal (TClass1::*function)(), TretVal& retVal)
585  {
586  auto t = std::make_tuple();
587  doSyncCall(instance, function, retVal, t);
588  }
589 
616  template<class TClass1, class TretVal, class TargCall, class Targ>
617  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall), TretVal& retVal, Targ& argument)
618  {
619  auto t = std::make_tuple(argument);
620  doSyncCall(instance, function, retVal, t);
621  std::tie(argument) = t;
622  }
623 
627  template<class TClass1, class TretVal, class TargCall, class Targ>
628  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall) const, TretVal& retVal, Targ& argument)
629  {
630  auto t = std::make_tuple(argument);
631  doSyncCall(instance, function, retVal, t);
632  std::tie(argument) = t;
633  }
634 
638  template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
639  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, Targ1Call), TretVal& retVal, Targ& argument, Targ1& argument1)
640  {
641  auto t = std::make_tuple(argument, argument1);
642  doSyncCall(instance, function, retVal, t);
643  std::tie(argument, argument1) = t;
644  }
648  template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
649  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, Targ1Call) const, TretVal& retVal, Targ& argument, Targ1& argument1)
650  {
651  auto t = std::make_tuple(argument, argument1);
652  doSyncCall(instance, function, retVal, t);
653  std::tie(argument, argument1) = t;
654  }
655 
659  template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
660  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2)
661  {
662  auto t = std::make_tuple(argument, argument1, argument2);
663  doSyncCall(instance, function, retVal, t);
664  std::tie(argument, argument1,argument2) = t;
665  }
666 
670  template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
671  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2) const, TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2)
672  {
673  auto t = std::make_tuple(argument, argument1, argument2);
674  doSyncCall(instance, function, retVal, t);
675  std::tie(argument, argument1,argument2) = t;
676  }
677 
681  template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class Targ, class Targ1, class Targ2, class Targ3>
682  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3)
683  {
684  auto t = std::make_tuple(argument, argument1, argument2, argument3);
685  doSyncCall(instance, function, retVal, t);
686  std::tie(argument, argument1,argument2, argument3) = t;
687  }
688 
692  template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class Targ, class Targ1, class Targ2, class Targ3, class Targ4>
693  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3, Targ4& argument4)
694  {
695  auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4);
696  doSyncCall(instance, function, retVal, t);
697  std::tie(argument, argument1,argument2, argument3, argument4) = t;
698  }
699 
703  template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class TargCall5, class Targ, class Targ1, class Targ2, class Targ3, class Targ4, class Targ5>
704  void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4, TargCall5), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3, Targ4& argument4, Targ5& argument5)
705  {
706  auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4, argument5);
707  doSyncCall(instance, function, retVal, t);
708  std::tie(argument, argument1,argument2, argument3, argument4, argument5) = t;
709  }
710 
714  void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
715  {
716  (void) handle;
717  (void) userData;
718  int numReads;
719  CAmDelegagePtr listPointers[3];
720  if ((numReads = read(pollfd.fd, &listPointers, sizeof(listPointers))) == -1)
721  {
722  logError("CAmSerializer::receiverCallback could not read pipe!");
723  throw std::runtime_error("CAmSerializer Could not read pipe!");
724  }
725  mListDelegatePoiters.assign(listPointers, listPointers + (numReads / sizeof(CAmDelegagePtr)));
726  }
727 
731  bool checkerCallback(const sh_pollHandle_t handle, void* userData)
732  {
733  (void) handle;
734  (void) userData;
735  if (mListDelegatePoiters.empty())
736  return (false);
737  return (true);
738  }
739 
743  bool dispatcherCallback(const sh_pollHandle_t handle, void* userData)
744  {
745  (void) handle;
746  (void) userData;
747  CAmDelegagePtr delegatePoiter = mListDelegatePoiters.front();
748  mListDelegatePoiters.pop_front();
749  if (delegatePoiter->call(mReturnPipe))
750  delete delegatePoiter;
751  if (mListDelegatePoiters.empty())
752  return (false);
753  return (true);
754  }
755 
759 
764  CAmSerializer(CAmSocketHandler *iSocketHandler) :
765  mPipe(), //
766  mReturnPipe(),//
767  mListDelegatePoiters(), //
771  {
772  assert(NULL!=iSocketHandler);
773 
774  if (pipe(mPipe) == -1)
775  {
776  logError("CAmSerializer could not create pipe!");
777  throw std::runtime_error("CAmSerializer Could not open pipe!");
778  }
779 
780  if (pipe(mReturnPipe) == -1)
781  {
782  logError("CAmSerializer could not create mReturnPipe!");
783  throw std::runtime_error("CAmSerializer Could not open mReturnPipe!");
784  }
785 
786  short event = 0;
787  sh_pollHandle_t handle;
788  event |= POLLIN;
789  iSocketHandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, handle);
790  }
791 
793  {
794  close(mPipe[0]);
795  close(mPipe[1]);
796  close(mReturnPipe[0]);
797  close(mReturnPipe[1]);
798  }
799 };
800 } /* namespace am */
801 #endif /* CAMSERIALIZER_H_ */
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 argument1, Targ2 &argument2), Targ argument, Targ1 argument1, Targ2 &argument2)
calls a function with three arguments asynchronously threadsafe.
magic class that does the serialization of functions calls The constructor must be called within the ...
Definition: CAmSerializer.h:49
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 argument1, Targ2 &argument2), Targ &argument, Targ1 argument1, Targ2 &argument2)
calls a function with three arguments asynchronously threadsafe.
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3)
calls a function with four arguments synchronously threadsafe.
template for a callback
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 &argument1, Targ2 &argument2), Targ &argument, Targ1 &argument1, Targ2 &argument2)
calls a function with three arguments asynchronously threadsafe.
void syncCall(TClass *instance, TRet(TClass::*method)(TArgs...), TRet &result, TArgs &...arguments)
calls a function with variadic arguments threadsafe
int getListDelegatePoiters()
get the size of delegate pointers
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2), Targ argument, Targ1 argument1, Targ2 argument2)
calls a function with three arguments asynchronously threadsafe.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 &argument1, Targ2 argument2), Targ &argument, Targ1 &argument1, Targ2 argument2)
calls a function with three arguments asynchronously threadsafe.
make private, not public template for a callback
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4, TargCall5), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3, Targ4 &argument4, Targ5 &argument5)
calls a function with six arguments synchronously threadsafe.
TAmShPollCheck< CAmSerializer > checkerCallbackT
The am::CAmSocketHandler implements a mainloop for the AudioManager.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 &argument1), Targ &argument, Targ1 &argument1)
calls a function with two arguments asynchronously threadsafe, both arguments are references...
uint16_t sh_pollHandle_t
this is a handle for a filedescriptor to be used with the SocketHandler
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 argument1, Targ2 argument2), Targ &argument, Targ1 argument1, Targ2 argument2)
calls a function with three arguments asynchronously threadsafe.
void doAsyncCall(Class intsance, Method method, Tuple &arguments)
instantiates a async delegate with given arguments and sends the delegate pointer over the pipe ...
SPDX license identifier: MPL-2.0.
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3, Targ4 &argument4)
calls a function with five arguments synchronously threadsafe.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &), Targ &argument)
calls a function with one argument called by reference asynchronously threadsafe
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(), TretVal &retVal)
calls a synchronous function with no arguments threadsafe
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall) const, TretVal &retVal, Targ &argument)
calls a function with one argument synchronous threadsafe for const functions.
am_Error_e addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void *userData, sh_pollHandle_t &handle)
Adds a filedescriptor to the polling loop.
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall), TretVal &retVal, Targ &argument)
calls a function with one argument synchronous threadsafe
template for a callback
CAmSerializer(CAmSocketHandler *iSocketHandler)
The constructor must be called in the mainthread context !
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, TargCall1, TargCall2), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2)
calls a function with three arguments synchronously threadsafe.
void doSyncCall(Class intsance, Method method, Return &result, Tuple &arguments)
instantiates a sync delegate with given arguments and sends the delegate pointer over the pipe ...
void asyncCall(TClass *instance, void(TClass::*function)())
calls a function with no arguments threadsafe
TAmShPollDispatch< CAmSerializer > dispatcherCallbackT
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 &argument1, Targ2 argument2), Targ argument, Targ1 &argument1, Targ2 argument2)
calls a function with three arguments asynchronously threadsafe.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3), Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3)
calls a function with four arguments asynchronously threadsafe.
void asyncCall(TClass *instance, TRet(TClass::*method)(TArgs...), TArgs &...arguments)
calls a function with variadic arguments threadsafe
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, Targ1Call) const, TretVal &retVal, Targ &argument, Targ1 &argument1)
calls a function with two arguments synchronously threadsafe const.
SPDX license identifier: MPL-2.0.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ &argument, Targ1 argument1), Targ &argument, Targ1 argument1)
calls a function with two arguments asynchronously threadsafe, first argument is a reference...
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 argument1), Targ argument, Targ1 argument1)
calls a function with two arguments asynchronously threadsafe.
void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
receiver callback for sockethandling, for more, see CAmSocketHandler
bool checkerCallback(const sh_pollHandle_t handle, void *userData)
checker callback for sockethandling, for more, see CAmSocketHandler
TAmShPollFired< CAmSerializer > receiverCallbackT
bool dispatcherCallback(const sh_pollHandle_t handle, void *userData)
dispatcher callback for sockethandling, for more, see CAmSocketHandler
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 &argument1, Targ2 &argument2), Targ argument, Targ1 &argument1, Targ2 &argument2)
calls a function with three arguments asynchronously threadsafe.
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, TargCall1, TargCall2) const, TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2)
calls a const function with three arguments synchronously threadsafe.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ argument, Targ1 &argument1), Targ argument, Targ1 &argument1)
calls a function with two arguments asynchronously threadsafe, second argument is a reference...
void syncCall(TClass1 *instance, TretVal(TClass1::*function)(TargCall, Targ1Call), TretVal &retVal, Targ &argument, Targ1 &argument1)
calls a function with two arguments synchronously threadsafe.
void asyncCall(TClass1 *instance, void(TClass1::*function)(Targ), Targ argument)
calls a function with one arguments asynchronously threadsafe