Hi,

I want to be able to declare a restriction in C++ so that a functor object can not change it's state or the state of any object it has a reference to upon calling the functor. This would have to be something like an "absolute const" object. At the same time I would like to be able to pass arguments upon calling the function object who's state it can change.

I need this because these functor objects will be scheduled between threads and I want to make sure that executing them only affects objects from the targeted thread, passed as arguments. This way I can guarantee no concurrency issues will occur.

something like this:
Code:
//instances on thread 1
class TargetedFunctor 
{
public:
    TargetedFunctor(...);
    virtual void operator(Target &target) absolute_const;
};
// At some point thread 1 calls
x.scheduleFunctor(f, 42);

//instances on thread 2
class Queue{
public:
    // threadsafe method
    void scheduleFunctor(absolute_const TargetedFuntor &f, Time when){
        ...
    }
};
//At time "when" thread 2 calls
f(target);
I fear that C++ supports no such restrictions. If so, does anyone know any C++ extensions or any other languages that do?