2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "AddonClass.h"
12 #include "CallbackFunction.h"
17 * This is the abstraction representing different ways to handle
18 * the execution of callbacks. Different language bindings may
19 * have different requirements.
21 class CallbackHandler
: public AddonClass
24 inline CallbackHandler() = default;
27 virtual void invokeCallback(Callback
* cb
) = 0;
31 * This class is primarily for Python support (hence the "Retarded"
32 * prefix). Python (et. al. Retarded languages) require that
33 * the context within which a callback executes is under the control
34 * of the language. Therefore, this handler is used to queue
35 * messages over to a language controlled thread for eventual
38 * @todo Allow a cross thread synchronous execution.
39 * Fix the stupid means of calling the clearPendingCalls by passing
40 * userData which is specific to the handler/language type.
42 class RetardedAsyncCallbackHandler
: public CallbackHandler
45 inline RetardedAsyncCallbackHandler() = default;
48 ~RetardedAsyncCallbackHandler() override
;
50 void invokeCallback(Callback
* cb
) override
;
51 static void makePendingCalls();
52 static void clearPendingCalls(void* userData
);
54 virtual bool isStateOk(AddonClass
* obj
) = 0;
55 virtual bool shouldRemoveCallback(AddonClass
* obj
, void* userData
) = 0;