2

Does Vibe.D have a build-in terminate function, for when the library is run through a static initializer? I want to terminate the application when vibe.d throws an exception when for example opening a file.

I have a server listening using the listenHTTP function.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
Jeroen
  • 15,257
  • 12
  • 59
  • 102

1 Answers1

5

Try getEventDriver().exitEventLoop();, from here and here.

EDIT: There's a simpler version, the standalone function vibe.core.core.exitEventLoop.

personak
  • 539
  • 4
  • 15
  • Does the `listenHTTP` function start an Event Loop? – Jeroen Feb 01 '14 at 22:54
  • No, it happens automatically in [`vibe.appmain`](https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/appmain.d), see the `runEventLoop()` call. – personak Feb 01 '14 at 23:11
  • I'm not really sure how the Event Loop relates to the `listenHTTP`. I'm not using `vibeappmain`. When I call `listenHTTP` inside the static constructor, my code runs fine and the HTTP Requests get handled. No event loop getting started. (Unless internally by `listenHTTP`, but if I put it inside the main method the program stops automatically unless I manually call `renEventLoop()`. – Jeroen Feb 05 '14 at 10:32
  • I see, without a main method it uses the vibe.d default one. Thanks. – Jeroen Feb 05 '14 at 20:16