Problem with function pointer
- From: Sohail Ahmed Siddiqui <sohail@xxxxxxxxxxxxxxx>
- Date: Thu, 04 May 2006 21:44:13 +0200
Hi,
i am working on a program which should connect to data server in one thread,
other threads will be used to update the UI and sorting data, in some of
the cases i have to use a function that should take int as parameter and in
some cases it has no parameter list. My class looks some thing like this
class FunctionThread : public Threads
{
public:
typedef int (*Function)();
FunctionThread(Function function,
size_t stackSize=StackSize::DEFAULT,
Priority priority=Priority::INHERIT,
SchedulingPolicy schedpol=SchedulingPolicy::INHERIT,
const std::string& name="",
bool detached=true);
protected:
virtual int run();
private:
Function function_;
};
my function which enables me to make different threads i am using
FunctionThread::FunctionThread(Function function,
size_t stackSize,
Priority priority,
SchedulingPolicy schedpol,
const std::string& name, bool detached)
: Threads(stackSize, priority, schedpol, name, detached,1)
{}
int FunctionThread::run()
{
return (*function_)();
}
This works very well with functions that have no parameters, but if i change
typedef int (*Function)(); to typedef int (*Function)(int); some how it
doesn't seem to work at all, can some one please tell me how can i change
this so that it can take int as normal parameters?
Br
Sohail
.
- Follow-Ups:
- Re: Problem with function pointer
- From: Sohail Ahmed Siddiqui
- Re: Problem with function pointer
- From: Ulrich Eckhardt
- Re: Problem with function pointer
- From: Philippe Amarenco
- Re: Problem with function pointer
- Prev by Date: Re: Can we use Message Queue for communication between POSIX threads (pthread)?
- Next by Date: Re: Problem with function pointer
- Previous by thread: Can we use Message Queue for communication between POSIX threads (pthread)?
- Next by thread: Re: Problem with function pointer
- Index(es):
Relevant Pages
|