Skip to content
This repository was archived by the owner on Feb 17, 2023. It is now read-only.
This repository was archived by the owner on Feb 17, 2023. It is now read-only.

Concurrency support? #57

@TheHackerDev

Description

@TheHackerDev

Does this support concurrent calls? It doesn't look like it, given that New() returns a pointer without a mutex to protect concurrent reads or writes.

This is important in the case of memory use on a web server, for example. I would rather initialize it once and call it repeatedly as opposed to re-initializing it on every client connection, which would end up needlessly adding and removing from the heap as well as increase the amount the garbage collector has to work.

Adding concurrency would simply be a matter of adding a sync.RWMutex field to the UserAgent struct, and calling the UserAgent.RWMutex field's RLock()/RUnlock() or Lock()/Unlock() methods in every library method that reads or writes to the struct, respectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions