mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
Improve ToggleRef release overhead.
Candidate patch provided by Andres in pull request #17. * glib/Object.cs: use ToggleRef.Dispose. * glib/ToggleRef.cs: implement IDisposable and expose former Free functionality as Dispose(). Free is now private non-lock taking called by Dispose and the idle queue handler.
This commit is contained in:
parent
10f4f03943
commit
4f42fb77fb
@ -69,7 +69,7 @@ namespace GLib {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
tref.Free ();
|
tref.Dispose ();
|
||||||
else
|
else
|
||||||
tref.QueueUnref ();
|
tref.QueueUnref ();
|
||||||
}
|
}
|
||||||
@ -429,7 +429,7 @@ namespace GLib {
|
|||||||
if (handle != IntPtr.Zero) {
|
if (handle != IntPtr.Zero) {
|
||||||
Objects.Remove (handle);
|
Objects.Remove (handle);
|
||||||
if (tref != null) {
|
if (tref != null) {
|
||||||
tref.Free ();
|
tref.Dispose ();
|
||||||
tref = null;
|
tref = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ using System.Runtime.InteropServices;
|
|||||||
|
|
||||||
namespace GLib {
|
namespace GLib {
|
||||||
|
|
||||||
internal class ToggleRef {
|
internal class ToggleRef : IDisposable {
|
||||||
|
|
||||||
bool hardened;
|
bool hardened;
|
||||||
IntPtr handle;
|
IntPtr handle;
|
||||||
@ -57,12 +57,16 @@ namespace GLib {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Free ()
|
public void Dispose ()
|
||||||
{
|
{
|
||||||
lock (PendingDestroys) {
|
lock (PendingDestroys) {
|
||||||
PendingDestroys.Remove (this);
|
PendingDestroys.Remove (this);
|
||||||
}
|
}
|
||||||
|
Free ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Free ()
|
||||||
|
{
|
||||||
if (hardened)
|
if (hardened)
|
||||||
g_object_unref (handle);
|
g_object_unref (handle);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user