Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 29377060: Noissue - add JsLocker which is merely v8::Locker but can be used with our JsEngine. (Closed)

Created:
Feb. 28, 2017, 12:01 p.m. by sergei
Modified:
Feb. 28, 2017, 10:45 p.m.
CC:
anton
Visibility:
Public.

Description

It's useful as a synchronization primitive in JsEngine and it will be used in next commits.

Patch Set 1 #

Total comments: 6
Unified diffs Side-by-side diffs Delta from patch set Stats (+17 lines, -4 lines) Patch
M src/JsContext.h View 2 chunks +9 lines, -2 lines 6 comments Download
M src/JsContext.cpp View 1 chunk +8 lines, -2 lines 0 comments Download

Messages

Total messages: 8
sergei
Feb. 28, 2017, 2:34 p.m. (2017-02-28 14:34:33 UTC) #1
Oleksandr
One nit. Otherwise LGTM. https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h File src/JsContext.h (right): https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h#newcode26 src/JsContext.h:26: class JsLocker { Nit: JsLocker ...
Feb. 28, 2017, 3:36 p.m. (2017-02-28 15:36:02 UTC) #2
Eric
https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h File src/JsContext.h (right): https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h#newcode26 src/JsContext.h:26: class JsLocker { I've been deep in this code, ...
Feb. 28, 2017, 4:26 p.m. (2017-02-28 16:26:44 UTC) #3
Oleksandr
https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h File src/JsContext.h (right): https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h#newcode26 src/JsContext.h:26: class JsLocker { On 2017/02/28 16:26:44, Eric wrote: > ...
Feb. 28, 2017, 5:33 p.m. (2017-02-28 17:33:56 UTC) #4
Eric
On 2017/02/28 17:33:56, Oleksandr wrote: >provided this is actually needed. I don't believe it's needed. ...
Feb. 28, 2017, 5:40 p.m. (2017-02-28 17:40:50 UTC) #5
sergei
https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h File src/JsContext.h (right): https://codereview.adblockplus.org/29377060/diff/29377061/src/JsContext.h#newcode26 src/JsContext.h:26: class JsLocker { On 2017/02/28 16:26:44, Eric wrote: > ...
Feb. 28, 2017, 10:14 p.m. (2017-02-28 22:14:48 UTC) #6
Eric
On 2017/02/28 22:14:48, sergei wrote: > Just wonder, could you give an example of a ...
Feb. 28, 2017, 10:30 p.m. (2017-02-28 22:30:19 UTC) #7
sergei
Feb. 28, 2017, 10:45 p.m. (2017-02-28 22:45:16 UTC) #8
Message was sent while issue was closed.
On 2017/02/28 22:30:19, Eric wrote:
> On 2017/02/28 22:14:48, sergei wrote:
> > Just wonder, could you give an example of a contemporary implementation of
> > shared_ptr based on mutexes?
> 
> Insofar as I know, most are. VS 2015 is, I'm pretty sure.
I'm absolutely sure that it's not the case because I have looked into the code
it.
> Not on std::mutex necessarily,
But the question was about mutex-based because lock-free and lock-based are
different worlds.
> but on some kind of multiprocessing primitive. It's a requirement
> of the standard that std::shared_ptr work in a multithreaded environment
without
> any special declaration. It was a debate during standardization whether they
> might have some policy argument or something that was a single-threaded
version,
> but consistency of use was thought to be superior.
> 
> Some newer compilers are using lock-free implementations, but that's a
> relatively recent development.
It depends how to define "recent".
> 
> > JIC, to clarify, I think that if there is no necessity then std::shared_ptr
> > should be passed by reference because "atomic" operations do have a
> considerable
> > cost. Although we might cannot notice the benefit from it now but it's
> > definitely a good practice to have.
> 
> Passing a raw pointer is even better unless you have a specific need to manage
> the lifespan of an argument past the scope of the function.
The usage of references is considered to be safer than usage of raw pointers and
I agree with it.
> Passing around
> shared_ptr because you don't want to think about life cycle issues just leads
> you down the path to self-reference and memory leaks.
Yes, but it's not related to the statement above.

Powered by Google App Engine
This is Rietveld