MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup … More...
Functions | |
void | MqMain (void *code) |
Main entrypoint - start the application | |
MqMsgque PACKAGE - the package-main is a single piece of code evaluated only once at application startup …
Example from MyServer.rb
→ The package-main configure the factory and start the server.
require "rbmqmsgque" include MqMsgque # package-item class MyServer < MqContextC # factory startup def initialize() super ConfigSetServerSetup(method(:ServerSetup)) end # define a service as link between the token "HLWO" and the callback "MyFirstService" def ServerSetup ServiceCreate("HLWO",method(:MyFirstService)) end # service to serve all incoming requests for token "HLWO" def MyFirstService() SendSTART() SendSTR(ReadSTR() + " World") SendRETURN() end end # ==================================================== # package-main # create the "MyServer" factory… and object srv = MqFactoryC.Add(MyServer).New() begin srv.LinkCreate(ARGV) srv.ProcessEvent(MqWaitOnEventE::FOREVER) rescue Exception => ex srv.ErrorCatch(ex) ensure srv.Exit() end
void MqMain | ( | void * | code | ) |
Main entrypoint - start the application
Tcl has a special requirement, for every new server-thread a new interpreter is created and
this interpreter source the toplevel file for initialization. This file is set on library startup and
can be changed with MqInitResetArg0. The problem is the server startup code from the toplevel. For internal
purpose this code should only be executed on application-startup (like the C main function)
and not for every thread again.