Re: NetHTTPd/Netplex subtasking

Pierre-Alexandre Voye <[email protected]> Thu, 10 Jan 2013 15:17:41 +0100
Newsgroups gmane.comp.lang.ocaml.lib.net.devel
Message-ID <CANnJ5GcmiMnBWZ_i=1XOLytVPD1iEu9PoO853g+xe-44AmUXiA@mail.gmail.com>
--===============7828141893586198414==
Content-Type: multipart/alternative; boundary=f46d040167f1b398a204d2efd8de

--f46d040167f1b398a204d2efd8de
Content-Type: text/plain; charset=UTF-8

I followed one of the simpler example (don't remember which one), in fact,
my app starts with this code :

let start handlers =
  let (option_list, cmdline_infos) = Netplex_main.args() in
(*  .... cut ... *)
 let nethttpd_factory =  Nethttpd_plex.nethttpd_factory  ~handlers:handlers
() in
  Netplex_main.startup  ( Netplex_mp.mp ~keep_fd_open:true () )
    Netplex_log.logger_factories
    Netplex_workload.workload_manager_factories
    [ nethttpd_factory ]
   cmdline_infos

Normally, only the threads will use the object.
Because of my inability to user shared memory, I don't have any byte of
global memory in this software (I use Memcache for that)

So, if i start a thread and return the string result, is there a risk that
the processes is killed by the master process before the thread finish his
job (In theory not) ?

2013/1/10 Gerd Stolpmann <[email protected]>

> Am Donnerstag, den 10.01.2013, 13:19 +0100 schrieb Pierre-Alexandre
> Voye:
>
> >
> > Can I use a thread without risk ?
>
> Normally, yes, if you ensure that library functions do not "see" that
> there are several threads, i.e. any object is only used by one thread at
> a time. There are normally no mutexes controlling parallel access
> built-in (except where described). There are also no global variables
> making multi-threading impossible (and if so, there are mutexes around
> them).
>
> I must admit that I do not exactly understand your architectural
> problem. What I've got is that
>
>  - You get a request via Nethttpd
>  - You call your service routine via the CGI-style interface
>  - that routine computes the result to return via CGI
>  - but that routine also needs to do some side work that is
>    not needed for the CGI return value, and could be run
>    outside the strict HTTP request/response cycle
>
> The answer to the question how you can run such side work depends very
> much on how you deploy Nethttpd. Do you use the Netplex containers, or
> did you follow one of the simpler examples?
>
> Gerd
>
>
>
> --
> ------------------------------------------------------------
> Gerd Stolpmann, Darmstadt, Germany    [email protected]
> Creator of GODI and camlcity.org.
> Contact details:        http://www.camlcity.org/contact.html
> Company homepage:       http://www.gerd-stolpmann.de
> *** Searching for new projects! Need consulting for system
> *** programming in Ocaml? Gerd Stolpmann can help you.
> ------------------------------------------------------------
>
>


-- 
---------------------
https://twitter.com/#!/ontologiae/
http://linuxfr.org/users/montaigne

--f46d040167f1b398a204d2efd8de
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><br></div>I followed one of the simpler example =
(don&#39;t remember which one), in fact, my app starts with this code :<br>=
<br>let start handlers =3D<br>=C2=A0 let (option_list, cmdline_infos) =3D N=
etplex_main.args() in<br>

</div>(*=C2=A0 .... cut ... *)<br><div>=C2=A0let nethttpd_factory =3D=C2=A0=
 Nethttpd_plex.nethttpd_factory=C2=A0 ~handlers:handlers () in<br>=C2=A0 Ne=
tplex_main.startup=C2=A0 ( Netplex_mp.mp ~keep_fd_open:true () )<br>=C2=A0=
=C2=A0=C2=A0 Netplex_log.logger_factories=C2=A0 <br>

=C2=A0=C2=A0=C2=A0 Netplex_workload.workload_manager_factories <br>=C2=A0=
=C2=A0=C2=A0 [ nethttpd_factory ]=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 <br>=C2=A0=C2=A0 cmdline_infos<br><br></div><div>Normally, onl=
y the threads will use the object.<br></div><div>Because of my inability to=
 user shared memory, I don&#39;t have any byte of global memory in this sof=
tware (I use Memcache for that)<br>

<br></div><div>So, if i start a thread and return the string result, is the=
re a risk that the processes is killed by the master process before the thr=
ead finish his job (In theory not) ?<br></div><div><div class=3D"gmail_extr=
a">

<br><div class=3D"gmail_quote">2013/1/10 Gerd Stolpmann <span dir=3D"ltr">&=
lt;<a href=3D"mailto:[email protected]" target=3D"_blank">info@gerd-st=
olpmann.de</a>&gt;</span><br><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1=
ex">

Am Donnerstag, den 10.01.2013, 13:19 +0100 schrieb Pierre-Alexandre<br>
Voye:<br>
<div><div class=3D"h5"><br>
&gt;<br>
&gt; Can I use a thread without risk ?<br>
<br>
</div></div>Normally, yes, if you ensure that library functions do not &quo=
t;see&quot; that<br>
there are several threads, i.e. any object is only used by one thread at<br=
>
a time. There are normally no mutexes controlling parallel access<br>
built-in (except where described). There are also no global variables<br>
making multi-threading impossible (and if so, there are mutexes around<br>
them).<br>
<br>
I must admit that I do not exactly understand your architectural<br>
problem. What I&#39;ve got is that<br>
<br>
=C2=A0- You get a request via Nethttpd<br>
=C2=A0- You call your service routine via the CGI-style interface<br>
=C2=A0- that routine computes the result to return via CGI<br>
=C2=A0- but that routine also needs to do some side work that is<br>
=C2=A0 =C2=A0not needed for the CGI return value, and could be run<br>
=C2=A0 =C2=A0outside the strict HTTP request/response cycle<br>
<br>
The answer to the question how you can run such side work depends very<br>
much on how you deploy Nethttpd. Do you use the Netplex containers, or<br>
did you follow one of the simpler examples?<br>
<br>
Gerd<br>
<div class=3D"im"><br>
<br></div>
<span class=3D""><font color=3D"#888888"><br>
--<br>
------------------------------------------------------------<br>
Gerd Stolpmann, Darmstadt, Germany =C2=A0 =C2=A0<a href=3D"mailto:gerd@gerd=
-stolpmann.de">[email protected]</a><br>
Creator of GODI and <a href=3D"http://camlcity.org" target=3D"_blank">camlc=
ity.org</a>.<br>
Contact details: =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"http://www.camlcity.=
org/contact.html" target=3D"_blank">http://www.camlcity.org/contact.html</a=
><br>
Company homepage: =C2=A0 =C2=A0 =C2=A0 <a href=3D"http://www.gerd-stolpmann=
.de" target=3D"_blank">http://www.gerd-stolpmann.de</a><br>
*** Searching for new projects! Need consulting for system<br>
*** programming in Ocaml? Gerd Stolpmann can help you.<br>
------------------------------------------------------------<br>
<br>
</font></span></blockquote></div><br><br clear=3D"all"><br>-- <br>---------=
------------<br><a href=3D"https://twitter.com/#%21/ontologiae/" target=3D"=
_blank">https://twitter.com/#!/ontologiae/</a><br><a href=3D"http://linuxfr=
.org/users/montaigne" target=3D"_blank">http://linuxfr.org/users/montaigne<=
/a><br>


</div></div></div>

--f46d040167f1b398a204d2efd8de--


--===============7828141893586198414==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
--===============7828141893586198414==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Ocamlnet-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ocamlnet-devel

--===============7828141893586198414==--