Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SchemaProxy mutex #163 #172

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Added SchemaProxy mutex #163 #172

merged 1 commit into from
Sep 18, 2023

Conversation

daveshanley
Copy link
Member

Rendering causes bits to be set on structs in the model. Concurrency causes race issues with reading a writing of these bits, as there is no locking in the model.

Until now. locking prevents concurrent renders that use a shared model from conflicting with one another.

Addresses #163 and pb33f/libopenapi-validator#23

Rendering causes bits to be set on structs in the model. Concurrency causes race issues with reading a writing of these bits, as there is no locking in the model.

Until now. locking prevents concurrent renders that use a shared model from conflicting with one another.

Addresses #163 and pb33f/libopenapi-validator#23

Signed-off-by: quobix <dave@quobix.com>
@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (dab6346) 99.80% compared to head (776c2fb) 99.80%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #172   +/-   ##
=======================================
  Coverage   99.80%   99.80%           
=======================================
  Files         148      148           
  Lines       10639    10643    +4     
=======================================
+ Hits        10618    10622    +4     
  Misses         21       21           
Flag Coverage Δ
unittests 99.80% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
datamodel/high/base/schema.go 100.00% <100.00%> (ø)
datamodel/high/base/schema_proxy.go 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@daveshanley daveshanley merged commit 53a46f4 into main Sep 18, 2023
3 checks passed
@daveshanley daveshanley deleted the v0.10.6 branch September 18, 2023 21:51
@jxsl13
Copy link

jxsl13 commented Sep 18, 2023

why is the mutex a pointer?

@daveshanley
Copy link
Member Author

My general rule is to ask myself "why should this NOT be a pointer". I generally 99% lean on pointer.

This is just a case of me defaulting on my coding behavior. If I pass around anything, I move it to a pointer, because I don't want to copy anything.

@jxsl13
Copy link

jxsl13 commented Sep 19, 2023

should a pointer to a mutex be copied?
I think that might lead to problems.
Go has a builtin detection for when a struct is copied that contains a mutex. If I'm not mistaken, a pointer mutex is not caught by that detection.

@daveshanley
Copy link
Member Author

I don't know, I haven't seen any literature saying that it's any different from a struct.

https://go.dev/src/sync/mutex.go

The receiver on Mutex is a pointer for Lock and Unlock

@jxsl13
Copy link

jxsl13 commented Sep 19, 2023

I am not sure on that one either, just having seen warnings pop up in the terminal when a struct with a mutex was copied.
So I'm wondering if anyone is supposed to copy the struct or not. Once you have multiple instances of the wrapping struct, all of them will refer to the same mutex. Dunno if thats wanted by you or not or if copying of the wrappung struct is wanted or not.
Just giving my two cents :). Do whatever you want with it.

@daveshanley
Copy link
Member Author

I've not seen any warnings pop up and the behavior is as I expect, tests pass accordingly. If any strangeness appears with this functionality, then I'll drop it back to a struct :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants