[gnome-builder] lsp: add helper for async calls



commit 2d31398197d1353a813645c4bd572943673cc13a
Author: Christian Hergert <chergert redhat com>
Date:   Thu Dec 5 13:25:02 2019 -0800

    lsp: add helper for async calls

 src/libide/lsp/ide-lsp-client.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/src/libide/lsp/ide-lsp-client.c b/src/libide/lsp/ide-lsp-client.c
index f171afb62..e36674d45 100644
--- a/src/libide/lsp/ide-lsp-client.c
+++ b/src/libide/lsp/ide-lsp-client.c
@@ -35,6 +35,12 @@
 #include "ide-lsp-client.h"
 #include "ide-lsp-enums.h"
 
+typedef struct
+{
+  JsonrpcClient *client;
+  GVariant      *id;
+} AsyncCall;
+
 typedef struct
 {
   DzlSignalGroup *buffer_manager_signals;
@@ -81,6 +87,32 @@ enum {
 static GParamSpec *properties [N_PROPS];
 static guint signals [N_SIGNALS];
 
+static AsyncCall *
+async_call_new (JsonrpcClient *client,
+                GVariant      *id)
+{
+  AsyncCall *ac = g_atomic_rc_box_new0 (AsyncCall);
+  ac->client = g_object_ref (client);
+  ac->id = g_variant_ref (id);
+  return ac;
+}
+
+static void
+async_call_finalize (gpointer data)
+{
+  AsyncCall *ac = data;
+  g_clear_object (&ac->client);
+  g_clear_pointer (&ac->id, g_variant_unref);
+}
+
+static void
+async_call_unref (gpointer data)
+{
+  g_atomic_rc_box_release_full (data, async_call_finalize);
+}
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (AsyncCall, async_call_unref);
+
 static gboolean
 ide_lsp_client_supports_buffer (IdeLspClient *self,
                                 IdeBuffer    *buffer)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]