-
Notifications
You must be signed in to change notification settings - Fork 197
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
c#: Use span and memory apis for primative type parameters #1138
base: main
Are you sure you want to change the base?
Conversation
45b1902
to
f1b9b92
Compare
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
f1b9b92
to
aa25aad
Compare
Streams also support
Maybe for some things we could generate both ? |
This is for the synchronous api though? I was thinking since we don't really support synchronous API's and we have p3 async coming down the line we might now be able to use
The issue I ran into was when list is used in a variant. I was initially going to generate both but then this seemed like an option. Reading up on Memory it sounds like it makes small heap based allocations for every memory held so this might not be the right option for a default. I will look to see if I can only generate this in the case of parameters and not for Variant based versions. I tried once but have a much better understanding of how it all comes together now. |
I've pushed a version that users Spans for any lists of primitive types and uses I think we will want/need to generate a second function that takes memory as well. The write use case is in the Stream API's WriteAsync method that takes |
bd38027
to
1bf7c22
Compare
1bf7c22
to
26b9360
Compare
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
26b9360
to
2241667
Compare
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
You are right, sorry. We can't have sync/blocking stream APIs until we have multi-threading. (Unless we are happy to block on the stream operation, blocking also other async tasks in the ST thread-pool. And I have strong opinion against that.) |
I've added additional functions so we can support Span and memory for arrays of primitive types like u8, etc. |
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Fixes: #1080 and follow up to #1122.
Putting in draft for now
since it has parts of #1137.This generates both Span and Memory function signatures for and function that has a canonical list type.
Note that no tests have to change since the memory/span API' provide implicit operators that automatically convert Byte Arrays to
Memory
. But I added an additional check to the test.