| 20 | = Common Services = |
| 21 | The plugin API provides some common services as found in a lot application specific plugin interfaces. |
| 22 | |
| 23 | == AppSched == |
| 24 | The AppSched is a way to allow the plugin to run event independed code. For example if the plugin copies data from one to another location AppSched is used to do that job. It is normally used to implement a main loop like structure. |
| 25 | |
| 26 | AppSched works by registering callbacks for special events. The following events are defined: |
| 27 | |
| 28 | ||= Event =||= Description =|| |
| 29 | ||INIT ||This is called when the application wants to start the plugin. Normally you run code to open IO or build data structures here. || |
| 30 | ||FREE ||This is called when the plugin is no longer used (on unload). You normally close all your IO and free memory you allocated here. || |
| 31 | ||UPDATE ||This is called when you should do a main loop iteration. You can check your IO here and do your work. This function must not block. This is normally called once per main loop cycle of the host application. || |
| 32 | ||TICK ||This is a an asynchronous event. Some applications use it when doing some longer work. It can be used to sync your IO like answer re-draw requests from the X server. You must not block in this function. || |
| 33 | ||WAIT ||This is to ask the plugin to block and wait for new work to be done. This is normally used to wait for new IO events such as data from clients or X11 events. This can block for a long time. UPDATE is called soon after this returned so you do not need to call it from here. || |
| 34 | |
| 35 | == Context separation == |
| 36 | The Plugin API supports context separation. This means that the plugin runs in it's own context and will not see the context of the host application or of other plugins. This also allows the same plugin to be loaded multiple times without them interacting. |
| 37 | |
| 38 | The following is currently supported context separation: |
| 39 | * libroar's error state |
| 40 | * system's error state |
| 41 | * global data of the plugin |
| 42 | * global notify core |
| 43 | |