Release 1.21.90
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.TaskPoolFunctionNative.cs
1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
3
4 namespace GstSharp {
5
6         using System;
7         using System.Runtime.InteropServices;
8
9 #region Autogenerated code
10         [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
11         internal delegate void TaskPoolFunctionNative(IntPtr user_data);
12
13         internal class TaskPoolFunctionInvoker {
14
15                 TaskPoolFunctionNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~TaskPoolFunctionInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal TaskPoolFunctionInvoker (TaskPoolFunctionNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal TaskPoolFunctionInvoker (TaskPoolFunctionNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal TaskPoolFunctionInvoker (TaskPoolFunctionNative native_cb, IntPtr data, GLib.DestroyNotify notify)
31                 {
32                         this.native_cb = native_cb;
33                         __data = data;
34                         __notify = notify;
35                 }
36
37                 internal Gst.TaskPoolFunction Handler {
38                         get {
39                                 return new Gst.TaskPoolFunction(InvokeNative);
40                         }
41                 }
42
43                 void InvokeNative ()
44                 {
45                         native_cb (__data);
46                 }
47         }
48
49         internal class TaskPoolFunctionWrapper {
50
51                 public void NativeCallback (IntPtr user_data)
52                 {
53                         try {
54                                 managed ();
55                                 if (release_on_call)
56                                         gch.Free ();
57                         } catch (Exception e) {
58                                 GLib.ExceptionManager.RaiseUnhandledException (e, false);
59                         }
60                 }
61
62                 bool release_on_call = false;
63                 GCHandle gch;
64
65                 public void PersistUntilCalled ()
66                 {
67                         release_on_call = true;
68                         gch = GCHandle.Alloc (this);
69                 }
70
71                 internal TaskPoolFunctionNative NativeDelegate;
72                 Gst.TaskPoolFunction managed;
73
74                 public TaskPoolFunctionWrapper (Gst.TaskPoolFunction managed)
75                 {
76                         this.managed = managed;
77                         if (managed != null)
78                                 NativeDelegate = new TaskPoolFunctionNative (NativeCallback);
79                 }
80
81                 public static Gst.TaskPoolFunction GetManagedDelegate (TaskPoolFunctionNative native)
82                 {
83                         if (native == null)
84                                 return null;
85                         TaskPoolFunctionWrapper wrapper = (TaskPoolFunctionWrapper) native.Target;
86                         if (wrapper == null)
87                                 return null;
88                         return wrapper.managed;
89                 }
90         }
91 #endregion
92 }