Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer currentValue = 0;
- void incrementMethod(void) {
- currentValue = currentValue + 1;
- }
- void decrementMethod(void) {
- currentValue = currentValue - 1;
- }
- integer getValueMethod(void) {
- return currentValue;
- }
- void setValueMethod(integer value) {
- currentValue = value;
- }
- integer currentValue = 0;
- void main(void) {
- while(running) {
- message = getMessage();
- switch(messsage->type) {
- case INCREMENT_REQUEST:
- incrementMethod();
- break;
- case DECREMENT_REQUEST:
- decrementMethod();
- break;
- case GET_VALUE_REQUEST:
- getValueMethod(message->senderID);
- break;
- case SET_VALUE_REQUEST:
- setValueMethod();
- break;
- default:
- sendMessage(senderID, UNKNOWN_REQUEST, NULL);
- }
- }
- }
- void incrementMethod(void) {
- currentValue = currentValue + 1;
- }
- void decrementMethod(void) {
- currentValue = currentValue - 1;
- }
- void getValueMethod(messagePort senderID) {
- sendMessage(senderID, GETVALUE_REPLY, currentValue);
- }
- void setValueMethod(integer value) {
- currentValue = value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement