Skip to content

Conversation

@hongliuliao
Copy link
Contributor

I think it's better delete m_arg by user than threadpool do it.
Because of two reason:

  1. Make it more flexible. User can delete m_arg in task or later.
  2. We can not sure m_arg is created by malloc or new.

not delete m_arg
@mbuljan
Copy link

mbuljan commented Oct 7, 2015

yup, this is a big problem. Task doesnt know how are the function parameters allocated and I dont think we can work around this except what you said or leave it like this and let the caller figure out that it all must be dynamically alocated because otherwise delete will break.

@mbuljan
Copy link

mbuljan commented Oct 7, 2015

We could make it so that we dont use the function pointer. Instead we make a Task an abstract class that has an abstract Execute() method that is called by run from the threadpool.

Then the client would have to inherit from Task, override Execute(), create an instance of his class and pass it, preferably, via reference to add method of threadpool

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

Successfully merging this pull request may close these issues.

2 participants