Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Conversation

@yowl
Copy link
Contributor

@yowl yowl commented Jul 26, 2020

This PR allows code to use emscripten_set_main_loop (https://emscripten.org/docs/api_reference/emscripten.h.html#browser-execution-environment).
This is possible with the .net 5 compiler and the use of e.g.

        [DllImport("*")]
        internal static extern unsafe void emscripten_set_main_loop(delegate*<void> f,  int fps, int simulate_infinite_loop);

        [UnmanagedCallersOnly(EntryPoint = "MainLoop", CallingConvention = CallingConvention.Cdecl)]
        static void MainLoop()
        {
            Console.WriteLine("Main loop");
        }

and

        emscripten_set_main_loop(&MainLoop, 0, 0);

It adds handling for TypeFlags.FunctionPointer and adds a call to RhpReversePInvokeReturn2 when the main function exits as emscripten will subsequently make calls into the main loop function and the thread state needs to go back to preemptive.

yowl added 2 commits July 25, 2020 19:21
Add a call to RhpReversePInvokeReturn2 when Main returns
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jkotas jkotas merged commit b1de467 into dotnet:master Aug 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants