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

multi: Make NewMessage() usable for creating messages for reading #591

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Commits on Aug 30, 2024

  1. multi: Use NewXXXMessage(nil) where possible

    This commit changes all occurrences of
    NewMessage(NewSingleSegmentArena(nil)) to NewSingleSegmentArena(nil) and
    all occurrences of NewMessage(NewMultiSegmentArena(nil)) to
    NewMultiSegmentArena(nil).
    
    Also, occurrences of Message{Arena: XXX} (where XXX is either a single
    or multi segment arena) are changed when possible as well.
    
    In the future, this will allow protecting Message values from wrong
    usage by enforcing the use of NewMessage to initialize message objects
    (instead of use of zero valued messages).
    matheusd committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    153d699 View commit details
    Browse the repository at this point in the history
  2. codec: Fix demux returning data to pool after Unmarshal

    The passed slice cannot be guaranteed to be from the pool, therefore it
    should not be returned there during Release.
    matheusd committed Aug 30, 2024
    Configuration menu
    Copy the full SHA
    f3cd4a7 View commit details
    Browse the repository at this point in the history

Commits on Sep 12, 2024

  1. Configuration menu
    Copy the full SHA
    480b5ba View commit details
    Browse the repository at this point in the history
  2. message: Make NewMessage usable for reading

    Previously, NewMessage() would always attempt to allocate the first
    word of the first segment and would consider arenas with more than 1
    segment as not usable.
    
    This restriction is lifted in this commit by only attempting to allocate
    the first segment and not the root pointer space. This allows passing a
    fully populated Arena object to Reset(), which in turns allows passing
    it to NewMessage.
    
    This will be helpful by ensuring NewMessage can be used in all
    situations where a message is needed (not just for writing).
    
    NOTE: this is a breaking API change. Before this commit, NewMessage
    would fail for read-only arenas or that otherwise could not allocate
    space for the root pointer.
    
    The allocation for the root pointer space is now enforced only when
    (1) performing an initial allocation or (2) setting the root pointer.
    
    Enforcement on (2) is only necessary because one call path in file
    fileparts.go makes a call to SetRoot before attempting to allocate space
    in the message. This is likely an erroneous call and should be
    investigated in the future in order to simplify the code.
    matheusd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    25dbad9 View commit details
    Browse the repository at this point in the history
  3. multi: Change all ocurrences to use NewMessage

    This changes all ocurrences of message instantiation to use
    NewMessage().
    
    This unifies all code for message init under a single code path.
    
    In the future, it may be possible to make all message fields unexported
    in order to better enforce message invariants.
    matheusd committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    dcb3395 View commit details
    Browse the repository at this point in the history