Abed,


Please take a look at 
https://github.com/crosswalk-project/realsense-extensions-crosswalk/blob/master/realsense/scene_perception/win/scene_perception_object.cc#L93,
 we use chromium 
base::Thread()<https://code.google.com/p/chromium/codesearch#chromium/src/base/threading/thread.h&q=base::thread&sq=package:chromium&type=cs>
 object, all works as wish.



And yes, PostMessage() from different thread is not secure way, could you try 
thread sharing mechanism to PostMessage from thread where the message get.



Thanks,

Halton.

> -----Original Message-----

> From: Khet, Abed

> Sent: Tuesday, March 08, 2016 8:00 PM

> To: Huo, Halton <[email protected]>; Alexis Menard <[email protected]>

> Cc: Boimel, Ohad <[email protected]>;

> [email protected]

> Subject: RE: [Crosswalk-help] [Asynchronous message posting] RE:

> Asynchronous message posting

>

> Hi Halton,

>

> I've already tried from before the solution you suggested. The result was that

> when I use std::thread is a crash in the extension. I suppose this occurred

> because PostMessage() when called to post the result back from different

> thread ID causes some crash.

> Do you have idea why this happens?

> Do you a code example for this?

>

> Thanks,

> Abed

>

> -----Original Message-----

> From: Huo, Halton

> Sent: Tuesday, March 08, 2016 12:22

> To: Khet, Abed <[email protected]<mailto:[email protected]>>; Alexis 
> Menard <[email protected]<mailto:[email protected]>>

> Cc: Boimel, Ohad <[email protected]<mailto:[email protected]>>;

> [email protected]<mailto:[email protected]>

> Subject: RE: [Crosswalk-help] [Asynchronous message posting] RE:

> Asynchronous message posting

>

> Hi Abed,

>

> I suppose the "send" and "abort" are JS functions, and they are async calls or

> Promises.

>

> Do you create a new thread on Crosswalk extension native code for "send"

> message handling? Otherwise, onMessage() will never be called again after

> your send_message_handling_func finished. That could explain why "abort"

> only reached after full execution.

>

> Thanks,

> Halton.

> > -----Original Message-----

> > From: Crosswalk-help

> > [mailto:[email protected]] On Behalf

> > Of Khet, Abed

> > Sent: Wednesday, March 02, 2016 6:32 PM

> > To: Alexis Menard <[email protected]<mailto:[email protected]>>

> > Cc: Boimel, Ohad <[email protected]<mailto:[email protected]>>;

> > [email protected]<mailto:[email protected]>

> > Subject: Re: [Crosswalk-help] [Asynchronous message posting] RE:

> > Asynchronous message posting

> >

> > Hi Alexis,

> >

> > I am still reading the article but I want to clear to you our use case:

> > We have a "send" operation which might take a long time. A user might

> > need to abort this operation using "abort" call.

> > We have tests in Crodova that call "send", and after 0.5 sec(for

> > example) "abort" is called, so the operation is aborted.

> > This is not the case in Crosswalk. "abort" reaches the extension just

> > after "send" completed totally its work and returns. This is the

> > problem we are facing and I wanted to learn from you how would you

> > suggest we solve this problem?

> >

> > Thanks,

> > Abed

> >

> > -----Original Message-----

> > From: Alexis Menard [mailto:[email protected]]

> > Sent: Monday, February 29, 2016 23:56

> > To: Khet, Abed <[email protected]<mailto:[email protected]>>

> > Cc: 
> > [email protected]<mailto:[email protected]>;
> >  Boimel, Ohad

> > <[email protected]<mailto:[email protected]>>

> > Subject: Re: [Asynchronous message posting] RE: [Crosswalk-help]

> > Asynchronous message posting

> >

> > On Mon, Feb 29, 2016 at 1:40 PM, Khet, Abed 
> > <[email protected]<mailto:[email protected]>> wrote:

> > > Thanks for your answer Alexis. I did not think it is not clear, else

> > > I was to clear

> > before.

> > >

> > > So I will explain the scenario as following:

> > >

> > > ## At Cross walk app Javascript side happens the following scenario:

> > >         1. Async Function A is called

> > >         2. Async Function B is called

> > >

> > >         A & B are invoking calls to the same crosswalk extension.

> > >

> > > ## At extension Side:

> > >         Happens today: function A is calling PostMessage. When it

> > > returns,

> > Function B calls PostMessage.

> >

> > I think this is the expected behavior. PostMessage will be called and

> > then the callback attached to it will be executed, then the context

> > return and you can execute more.

> >

> > >         Expected Behavior: PostMessage should be called in Parallel

> > > on

> > two different threads.

> >

> > Nope there is no such mechanism in place.

> >

> > >

> > > Javascript interpreters are supporting parallel execution and event

> > > driven

> > model. This is not working for extensions as I described.

> >

> > Nope some tasks are happening in parallel but unless you use something

> > like Web Worker there is not parallelism out of the box in JavaScript.

> >

> > https://blog.mozilla.org/javascript/2015/02/26/the-path-to-parallel-ja

> > vascript/

> > is a good article about it.

> >

> > > If this is not clear I prefer to set a meeting with you so I show

> > > you the

> > problem.

> > >

> > > Thanks,

> > > Abed

> > >

> > >

> > >

> > > -----Original Message-----

> > > From: Alexis Menard [mailto:[email protected]]

> > > Sent: Monday, February 29, 2016 23:30

> > > To: Khet, Abed <[email protected]<mailto:[email protected]>>

> > > Cc: 
> > > [email protected]<mailto:[email protected]>;
> > >  Boimel, Ohad

> > > <[email protected]<mailto:[email protected]>>

> > > Subject: Re: [Crosswalk-help] Asynchronous message posting

> > >

> > > Hi,

> > >

> > > I don't understand the context. In one side you are talking about

> > > some JS

> > execution then you talk about C++ and threads. Hard to get the big

> > picture. Can you post a snipped of code/pseudo code of what you're trying to

> achieve.

> > >

> > > But the behavior you describe is what setTimeout would normally do

> > > if say

> > the delay is the same. Calls are getting queued and then triggered.

> > >

> > > Thanks.

> > >

> > > On Thu, Feb 18, 2016 at 9:27 AM, Khet, Abed 
> > > <[email protected]<mailto:[email protected]>>

> wrote:

> > >> Hi,

> > >>

> > >>

> > >>

> > >> I have the following line in my initialization function:

> > >>

> > >> g_messaging->Register(extension, handle_message);

> > >>

> > >>

> > >>

> > >> where g_messaging is from XW_MessagingInterface type.

> > >>

> > >>

> > >>

> > >> According to the documentation in the header file this function

> > >> (handle_message) should be an called as an asynchronous messaging

> > >> function and can be called in parallel form Javascript part. What

> > >> happens is that even that calls in javascript that are fired using

> > >> setTimeout JS function are being called serially one by one where

> > >> the second one is called totally when the first one finishes its 
> > >> processing.

> > >>

> > >> I’ve tried solving this by using std::thread for each task

> > >> depending on the fact the PostMessage function

> > >> (XW_MessagingInterface_1::PostMessage) – but this caused a crash in

> > >> the

> > extension.

> > >>

> > >>

> > >>

> > >> How could I use asynchronous messaging in Crosswalk extension?

> > >>

> > >>

> > >>

> > >> Thanks,

> > >>

> > >> Abed

> > >>

> > >>

> > >>

> > >> -------------------------------------------------------------------

> > >> --

> > >> Intel Israel (74) Limited

> > >>

> > >> This e-mail and any attachments may contain confidential material

> > >> for the sole use of the intended recipient(s). Any review or

> > >> distribution by others is strictly prohibited. If you are not the

> > >> intended recipient, please contact the sender and delete all copies.

> > >>

> > >>

> > >> _______________________________________________

> > >> Crosswalk-help mailing list

> > >> [email protected]<mailto:[email protected]>

> > >> https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

> > >>

> > > --------------------------------------------------------------------

> > > -

> > > Intel Israel (74) Limited

> > >

> > > This e-mail and any attachments may contain confidential material

> > > for the sole use of the intended recipient(s). Any review or

> > > distribution by others is strictly prohibited. If you are not the

> > > intended recipient, please contact the sender and delete all copies.

> > ---------------------------------------------------------------------

> > Intel Israel (74) Limited

> >

> > This e-mail and any attachments may contain confidential material for

> > the sole use of the intended recipient(s). Any review or distribution

> > by others is strictly prohibited. If you are not the intended

> > recipient, please contact the sender and delete all copies.

> > _______________________________________________

> > Crosswalk-help mailing list

> > [email protected]<mailto:[email protected]>

> > https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help
_______________________________________________
Crosswalk-help mailing list
[email protected]
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help

Reply via email to