6#define CDEBUG(...) Ase::debug ("callback", __VA_ARGS__)
13 memset (mem_, 0,
sizeof (mem_));
19 memcpy (mem_, other.mem_, sizeof (other.mem_));
22const RtCall::Callable*
23RtCall::callable ()
const
25 if (mem_[0] == 0 && mem_[1] == 0 && mem_[2] == 0 && mem_[3] == 0)
27 return reinterpret_cast<const Callable*
> (unalias_ptr (&mem_[0]));
32 struct Wrapper : Callable {
33 Wrapper (
void (*f) ()) : f_ (f) {}
34 void call()
const override {
return f_ (); }
37 static_assert (
sizeof (mem_) >=
sizeof (Wrapper));
38 Wrapper *w =
new (mem_) Wrapper { f };
45 const Callable *wcallable = callable();
50void RtCall::Callable::call ()
const {}
53JobQueue::JobQueue (
const Caller &caller) :
70 const size_t aid = cbl->add ([&r] (
const char *delim) { r += delim; r +=
"a"; });
71 const size_t bid = cbl->add ([&r,&cbl,aid] (
const char *delim) { r += delim; r +=
"b"; cbl->del (aid); });
72 const size_t cid = cbl->add ([&r] (
const char *delim) { r += delim; r +=
"c"; });
76 assert (r ==
"+a+b+c|b|c");
79 assert (r ==
"+a+b+c|b|c*c");
82 assert (r ==
"+a+b+c|b|c*c");
Reentrant callback list with configurable arguments.
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
#define TEST_INTEGRITY(FUNC)
Register func as an integrity test.
The Anklang C++ API namespace.
Wrap simple callback pointers, without using malloc (obstruction free).
void invoke()
Invoke the wrapped function call.
~RtCall()
Clear function pointers.
RtCall(T &o, void(T::*f)())
Wrap a simple void func() object member function call.