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

buffer inside another container? #34

Closed
mario-tux opened this issue Oct 26, 2018 · 8 comments
Closed

buffer inside another container? #34

mario-tux opened this issue Oct 26, 2018 · 8 comments
Assignees

Comments

@mario-tux
Copy link

I've defined a buffer (as queue) of elementary types but it looks I can't use it inside another container (a tuple). Maybe this is related to the fact that I was not able to find a macro like BUFFER_OPLIST to define the respective oplist.

I want to do something like:

BUFFER_DEF(int_queue, int, 10,
           BUFFER_QUEUE | BUFFER_BLOCKING | BUFFER_THREAD_SAFE,
           M_DEFAULT_OPLIST)
TUPLE_DEF2(my_tuple, (a_queue, int_queue_t), (a_number, int))
@P-p-H-d
Copy link
Owner

P-p-H-d commented Oct 26, 2018

As you may have noticed, the last lines of m-buffer are:

// NOTE: SET & INIT_SET are deliberately missing. TBC if it the right way.
// NOTE: There is no oplist defined for this container.

In fact, the queue as a synchronization should be a global variable. so I was thinking if it made sense to encapsulate it into another container? But maybe for tuple, it makes sense and I am overthinking :)

@P-p-H-d P-p-H-d self-assigned this Oct 26, 2018
@mario-tux
Copy link
Author

I got several threads that share a bunch of structures (to be accessed in a safe way). They are not defined as global variables as I don't like their use (except when it is strictly necessary): I would define a structure (but I would use a tuples as substitute) that is passed by reference to the thread functions. This means that I would require the SET/INIT_SET methods and the possibility to embed buffers inside another containers. Tell me what do you think about such use and if you are going to implement such possibility. Otherwise I can clearly revert on a classic structure.

@P-p-H-d
Copy link
Owner

P-p-H-d commented Oct 26, 2018

Ok for implementation.

@mario-tux
Copy link
Author

I worried by the presence of the size parameter in the init method of a buffer. How can it be recursively managed by the init method of the container?

@P-p-H-d
Copy link
Owner

P-p-H-d commented Oct 26, 2018

I plan to support only size defined at compilation time (and create a specialized initialize function that takes only the buffer as argument).

@P-p-H-d
Copy link
Owner

P-p-H-d commented Oct 27, 2018

The methods INIT & INIT_SET have been done for the buffer, including the BUFFER oplist.
But I still have a constness issue to solve before considering the ticket as closed.

@P-p-H-d
Copy link
Owner

P-p-H-d commented Oct 27, 2018

It should work now in 'master'.

@mario-tux
Copy link
Author

Yes, it looks to work. Thank you.

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

No branches or pull requests

2 participants