1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#pragma once
#include "Core/StrBuf.h"
#include "NamedThread.h"
namespace storm {
STORM_PKG(core.lang);
/**
* Specifies on which thread a specific function is to be run.
*/
class RunOn {
STORM_VALUE;
public:
enum State {
// Run anywhere. This is used when no threading constraint has been declared, and is the
// default value of this class.
any,
// The thread to run on is decided at runtime. For example, when a class has been
// declared to run on a thread provided runtime.
runtime,
// The thread is known compile-time. Find the thread in the 'thread' member.
named,
};
// State.
State state;
// Thread. Only valid if 'state == named'.
MAYBE(NamedThread *) thread;
// Create.
STORM_CTOR RunOn();
STORM_CTOR RunOn(State s);
STORM_CTOR RunOn(NamedThread *thread);
// Assuming we're running on a thread represented by 'this', may we run a function declared
// to run on 'other' without sending messages?
Bool STORM_FN canRun(RunOn other) const;
// Output.
void STORM_FN toS(StrBuf *to) const;
};
// Output.
wostream &operator <<(wostream &to, const RunOn &v);
}
|