discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Iterating Glib's GMainLoop with NSRunLoop


From: Hugo Melder
Subject: Re: Iterating Glib's GMainLoop with NSRunLoop
Date: Thu, 7 Sep 2023 01:06:20 +0200

Thank you Ondrej!

> On 6. Sep 2023, at 23:02, Ondrej Florian <onflapp@yahoo.com> wrote:
> 
> Hi Hugo,
> 
> using timer is not that bad and it has been used in the wild.
> For example: 
> https://github.com/onflapp/nextspace/blob/master/Frameworks/SystemKit/OSEUDisksAdaptor.m
> 
> 
> On 2023-09-05 15:28:39 +0200 Hugo Melder <admin@hugomelder.com> wrote:
> 
>> Hey,
>> 
>> I am currently using GStreamer as part of a project, and started using 
>> Objective-C for non-GStreamer components of the application.
>> The loads of macros and boilerplate were just to much…
>> 
>> However, I am currently stuck at integrating (At the moment only iterating) 
>> the Glib mainloop.
>> The Glib provides the GMainLoop, which is similar to NSRunLoop and can be 
>> manually iterated:
>> 
>> loop->is_running = TRUE;
>> while (loop->is_running)
>>  {
>>    g_main_context_iteration (context, TRUE);
>>  }
>> 
>> The second argument of g_main_context_iteration indicates whether the 
>> iteration should block.
>> 
>> I thought about using an NSTimer with a high polling frequency, but that 
>> seems like a hack to me. Is there a better way (maybe even a GNUstep 
>> specific 
>> one) to install a hook into the runloop? The RunLoop Observer APIs does not 
>> seem to be available with GNUstep’s NSRunLoop implementation.
>> 
>> Writing a GMainLoop compatible “class”, and bridging to the NSRunLoop by 
>> translating all Glib Events would be a more complex solution.
>> 
>> Any ideas or tips are welcome :)
>> 
>> Best Regards,
>> 
>> Hugo
>> 
>> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]