00001 #ifndef SCHEDULE_ACTOR_CLASS 00002 #define SCHEDULE_ACTOR_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : schedule_actor * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 1991-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "scheduling_common.h" 00019 00020 // forward. 00021 class schedulable; 00022 00024 00031 class SCHEDULING_CLASS_STYLE schedule_actor : public scheduling_common 00032 { 00033 public: 00034 virtual int actor_id() const = 0; 00036 00037 IMPLEMENT_CLASS_NAME("schedule_actor"); 00038 00039 // in the schedulable management functions below, the schedulable must be 00040 // locked prior to calling the function specified. thus the derived 00041 // schedule_actor is assured that it is the only one possessing the lock 00042 // on the schedulable, which at least ensures that no other scheduling 00043 // function is active on it. 00044 // 00045 // the derived schedule_actor, on the other hand, must take care of its own 00046 // thread safety. it must be safe for multiple threads to call the 00047 // management functions on different schedulable objects. this is especially 00048 // important if those management functions are allowed to manipulate any 00049 // data owned by the derived schedule_actor or other classes. 00050 00051 virtual outcome preprocess(schedulable &to_process) = 0; 00053 00057 virtual outcome activate(schedulable &to_activate, int time_allowed) = 0; 00059 00061 virtual outcome expiration(schedulable &to_expire) = 0; 00063 00066 virtual void postprocess(schedulable &to_process) = 0; 00068 00069 }; 00070 00072 00074 00081 class SCHEDULING_CLASS_STYLE actor_mapping 00082 { 00083 public: 00084 actor_mapping(schedule_actor &actor) : _actor(actor) {} 00085 virtual ~actor_mapping(); 00086 schedule_actor &_actor; 00087 }; 00088 00090 00092 00100 class SCHEDULING_CLASS_STYLE actor_mapper 00101 { 00102 public: 00103 virtual ~actor_mapper(); 00104 virtual actor_mapping *open_actor(int actor_id) = 0; 00106 00109 virtual void close_actor(actor_mapping *to_close) = 0; 00111 00114 }; 00115 00116 #endif 00117
1.5.1