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

Make circular buffer thread-safe #19

Open
wallento opened this issue Jan 25, 2016 · 7 comments
Open

Make circular buffer thread-safe #19

wallento opened this issue Jan 25, 2016 · 7 comments

Comments

@wallento
Copy link
Member

I think making the circular buffer thread-safe is a first step towards #8

@imphil
Copy link
Member

imphil commented Jan 25, 2016

cbuf already has single reader/writer semantics, as expected from a FIFO (see http://www.glip.io/group__development-cbuf.html). What kind of thread-safety are you looking for?

@wallento
Copy link
Member Author

multiple producer, single consumer for outgoing and single producer, multiple consumer for outgoing. I think the userspace should be allowed to be multithreaded.

@imphil
Copy link
Member

imphil commented Jan 25, 2016

What's the specific use case for that? And how common is it to justify putting the locking overhead into the library itself, as opposed to letting the user of the library add locking if necessary?

@wallento
Copy link
Member Author

It should be used to a NBDS then anyways. We are already locking at each access, so even moving the lock a bit does not harm for the moment. Overall nothing urgent, but thread-safety is important.

@wallento
Copy link
Member Author

Use case: Generating data from multiple threads

@imphil
Copy link
Member

imphil commented Jan 25, 2016

From all cases I can think of and have implemented, the application that uses GLIP is implementing a higher-level protocol on top of the FIFO semantics provided by GLIP. Almost all protocols rely on specific data ordering. To provide this data ordering, a sequential write or read is necessary.

If the data is written or read ordered, already an implicit locking is present in the user's code and there's no need for concurrent access to the read or write functions.

Therefore, could you please sketch a specific use case where we
a) have a protocol which does not require sequential reading/writing of data
b) gain performance or other benefits by doing the required locking inside GLIP.

Independent of that, as you mentioned, the implementation of the cbuf read/write functions could be improved to be non-blocking. Doing this is, however, independent of the question what thread safety guarantees cbuf should provide.

@wallento
Copy link
Member Author

Regarding your question, full thread-safety is the best and favorable property on the glip API in general

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

No branches or pull requests

2 participants