- Added requests system

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@652 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-06-22 22:48:33 +00:00
parent d8cd3577a7
commit 56db7cd6a2
23 changed files with 980 additions and 40 deletions

View File

@ -145,7 +145,10 @@ src_backend_libbackend_la_LDFLAGS = \
# Please keep this in sorted order:
src_backend_libbackend_la_SOURCES = \
src/backend/dynamic_process.cc \
src/backend/dynamic_request.cc \
src/backend/dynamic_resource.cc \
src/backend/dynamic_schedulable.cc \
src/backend/dynamic_sub_request.cc \
src/backend/dynamic_thread.cc \
src/backend/global_preferences.cc \
src/backend/history.cc \
@ -155,21 +158,30 @@ src_backend_libbackend_la_SOURCES = \
src/backend/policy_manager.cc \
src/backend/policy_parameters.cc \
src/backend/process.cc \
src/backend/request.cc \
src/backend/resource.cc \
src/backend/schedulable.cc \
src/backend/schedulable_queue.cc \
src/backend/scheduler.cc \
src/backend/slice.cc \
src/backend/static_process.cc \
src/backend/static_request.cc \
src/backend/static_resource.cc \
src/backend/static_schedulable.cc \
src/backend/static_sub_request.cc \
src/backend/static_thread.cc \
src/backend/string_utils.cc \
src/backend/sub_request.cc \
src/backend/thread.cc \
src/backend/user_interrupt_exception.cc
pkginclude_HEADERS += \
config.h \
src/backend/dynamic_process.hh \
src/backend/dynamic_request.hh \
src/backend/dynamic_resource.hh \
src/backend/dynamic_schedulable.hh \
src/backend/dynamic_sub_request.hh \
src/backend/dynamic_thread.hh \
src/backend/global_preferences.hh \
src/backend/history.hh \
@ -179,15 +191,21 @@ pkginclude_HEADERS += \
src/backend/policy.hh \
src/backend/policy_manager.hh \
src/backend/policy_parameters.hh \
src/backend/request.hh \
src/backend/resource.hh \
src/backend/process.hh \
src/backend/schedulable.hh \
src/backend/schedulable_queue.hh \
src/backend/scheduler.hh \
src/backend/slice.hh \
src/backend/static_process.hh \
src/backend/static_request.hh \
src/backend/static_resource.hh \
src/backend/static_schedulable.hh \
src/backend/static_sub_request.hh \
src/backend/static_thread.hh \
src/backend/string_utils.hh \
src/backend/sub_request.hh \
src/backend/thread.hh \
src/backend/user_interrupt_exception.hh

View File

@ -20,7 +20,7 @@
#include "dynamic_process.hh"
#include "static_process.hh"
#include "dynamic_thread.hh"
#include <cassert>
using namespace sgpem;
@ -34,21 +34,18 @@ DynamicProcess::DynamicProcess(StaticProcess* core) :
DynamicProcess::DynamicProcess(const DynamicProcess &other) :
Schedulable(), DynamicSchedulable(other), Process()
{
typedef vector<DynamicThread*>::iterator ThreadIt;
typedef vector<DynamicThread*>::const_iterator ThreadIt;
const vector<DynamicThread*>& other_threads = other._dynamic_threads;
// FIXME uncomment when DynamicThread is complete
// for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
// _dynamic_threads.push_back(new DynamicThread(*(*it)));
for(ThreadIt it = other_threads.begin(); it != other_threads.end(); ++it)
_dynamic_threads.push_back(new DynamicThread(*(*it)));
}
std::vector<Thread*>
DynamicProcess::get_threads()
{
//FIXME uncomment when DynamicThread is complete
//return vector<Thread*>(_dynamic_threads.begin(), _dynamic_threads.end());
return vector<Thread*>();
return vector<Thread*>(_dynamic_threads.begin(), _dynamic_threads.end());
}
Schedulable::state
@ -64,17 +61,16 @@ DynamicProcess::remove_thread(Thread* thread)
{
assert(thread != NULL);
//FIXME uncomment me once DynamicThread is complete
//vector<DynamicThread*>::iterator it;
vector<DynamicThread*>::iterator it;
//it = std::find(_dynamic_threads.begin(), _dynamic_threads.end(), thread);
it = std::find(_dynamic_threads.begin(), _dynamic_threads.end(), thread);
if(it != _dynamic_threads.end())
{
_dynamic_threads.erase(it);
delete *it;
}
//if(it != _dynamic_threads.end())
//{
// _dynamic_threads.erase(it);
// delete *it;
//}
//
}
void

View File

@ -0,0 +1,91 @@
// src/backend/dynamic_request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "dynamic_request.hh"
#include "static_request.hh"
#include "dynamic_sub_request.hh"
#include <cassert>
using namespace sgpem;
using std::vector;
DynamicRequest::DynamicRequest(StaticRequest *core,
DynamicThread* owner) :
_static_request(core), _dynamic_thread(owner),
_state(state_ready)
{
assert(core != NULL);
assert(owner != NULL);
}
vector<SubRequest*>
DynamicRequest::get_subrequests()
{
return vector<SubRequest*>(_dynamic_subrequests.begin(), _dynamic_subrequests.end());
}
DynamicThread&
DynamicRequest::get_thread()
{
return *_dynamic_thread;
}
unsigned int
DynamicRequest::get_instant() const
{
return _static_request->get_instant();
}
Request::state
DynamicRequest::get_current_state() const
{
return _state;
}
void
DynamicRequest::add_subrequest(DynamicSubRequest* subreq)
{
assert(subreq != NULL);
_dynamic_subrequests.push_back(subreq);
}
void
DynamicRequest::remove_subrequest(SubRequest* subreq)
{
assert(subreq != NULL);
vector<DynamicSubRequest*>::iterator it;
it = std::find(_dynamic_subrequests.begin(), _dynamic_subrequests.end(), subreq);
if(it != _dynamic_subrequests.end())
{
_dynamic_subrequests.erase(it);
delete *it;
}
}
void
DynamicRequest::serialize(SerializeVisitor& translator) const
{
// Let a drunk monkey write this code ;P
}

View File

@ -0,0 +1,66 @@
// src/backend/dynamic_request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef DYNAMIC_REQUEST_HH
#define DYNAMIC_REQUEST_HH 1
#include "config.h"
#include "../templates/smartp.hh"
#include <vector>
#include "request.hh"
#include "static_request.hh"
namespace sgpem
{
class DynamicRequest;
class SerializeVisitor;
class DynamicThread;
class SubRequest;
class DynamicSubRequest;
class DynamicRequest : public Request
{
public:
DynamicRequest(StaticRequest *core, DynamicThread* owner);
std::vector<SubRequest*> get_subrequests();
DynamicThread& get_thread();
unsigned int get_instant() const;
state get_current_state() const;
void add_subrequest(DynamicSubRequest* subreq);
void remove_subrequest(SubRequest* subreq);
void serialize(SerializeVisitor& translator) const;
private:
memory::smart_ptr<StaticRequest> _static_request;
DynamicThread* _dynamic_thread;
state _state;
std::vector<DynamicSubRequest*> _dynamic_subrequests;
};
}
#endif

View File

@ -0,0 +1,48 @@
// src/backend/dynamic_resource.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "dynamic_resource.hh"
#include "static_resource.hh"
using namespace sgpem;
DynamicResource::DynamicResource(StaticResource *core) :
_static_resource(core)
{
}
Glib::ustring
DynamicResource::get_name() const
{
return _static_resource->get_name();
}
unsigned int
DynamicResource::get_places() const
{
return _static_resource->get_places();
}
void
DynamicResource::serialize(SerializeVisitor& translator) const
{
// Let a drunk monkey write this code ;P
}

View File

@ -0,0 +1,53 @@
// src/backend/dynamic_resource.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef DYNAMIC_RESOURCE_HH
#define DYNAMIC_RESOURCE_HH 1
#include "config.h"
#include "glibmm/ustring.h"
#include "../templates/smartp.hh"
#include "resource.hh"
namespace sgpem
{
class DynamicResource;
class SerializeVisitor;
class StaticResource;
class DynamicResource : public Resource
{
public:
DynamicResource(StaticResource *core);
Glib::ustring get_name() const;
unsigned int get_places() const;
void serialize(SerializeVisitor& translator) const;
private:
memory::smart_ptr<StaticResource> _static_resource;
};
}
#endif

View File

@ -0,0 +1,69 @@
// src/backend/dynamic_sub_request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "dynamic_sub_request.hh"
using namespace sgpem;
DynamicSubRequest::DynamicSubRequest(StaticSubRequest* core,
DynamicResource* resource) :
_static_subrequest(core), _dynamic_resource(resource),
_queue_position(-1)
{
assert(core != NULL);
assert(resource != NULL);
}
DynamicResource&
DynamicSubRequest::get_resource()
{
return *_dynamic_resource;
}
unsigned int
DynamicSubRequest::get_places() const
{
return _static_subrequest->get_places();
}
unsigned int
DynamicSubRequest::get_length() const
{
return _static_subrequest->get_length();
}
int
DynamicSubRequest::get_queue_position() const
{
return _queue_position;
}
void
DynamicSubRequest::set_queue_position(int position)
{
_queue_position = position;
}
void
DynamicSubRequest::serialize(SerializeVisitor& translator) const
{
//blah blah blah TODO
}

View File

@ -0,0 +1,61 @@
// src/backend/dynamic_sub_request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef DYNAMIC_SUB_REQUEST_HH
#define DYNAMIC_SUB_REQUEST_HH 1
#include "config.h"
#include "sub_request.hh"
#include "dynamic_resource.hh"
#include "static_sub_request.hh"
namespace sgpem
{
class DynamicSubRequest;
class SerializeVisitor;
class Resource;
class StaticSubRequest;
class DynamicSubRequest : public SubRequest
{
public:
DynamicSubRequest(StaticSubRequest* core, DynamicResource* resource);
DynamicResource& get_resource();
unsigned int get_places() const;
unsigned int get_length() const;
int get_queue_position() const;
void set_queue_position(int position);
void serialize(SerializeVisitor& translator) const;
private:
memory::smart_ptr<StaticSubRequest> _static_subrequest;
DynamicResource* _dynamic_resource;
int _queue_position;
};
}
#endif

View File

@ -20,7 +20,7 @@
#include "dynamic_thread.hh"
#include "static_thread.hh"
#include "dynamic_request.hh"
#include <cassert>
using namespace sgpem;
@ -35,16 +35,15 @@ DynamicThread::DynamicThread(StaticThread* core, DynamicProcess* parent) :
DynamicThread::DynamicThread(const DynamicThread &other) :
Schedulable(), DynamicSchedulable(other), Thread()
{
typedef vector<DynamicRequest*>::iterator ReqIt;
typedef vector<DynamicRequest*>::const_iterator ReqIt;
const vector<DynamicRequest*>& other_req = other._dynamic_requests;
_state = other._state;
_parent = other._parent;
// FIXME uncomment me once requests are ready
// for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
// _dynamic_requests.push_back(new DynamicRequest(*(*it)));
for(ReqIt it = other_req.begin(); it != other_req.end(); ++it)
_dynamic_requests.push_back(new DynamicRequest(*(*it)));
}
DynamicProcess&
@ -71,9 +70,7 @@ DynamicThread::set_state(state new_state)
vector<Request*>
DynamicThread::get_requests()
{
// FIXME uncomment once requests are compelted
//return vector<Request*>(_dynamic_requests.begin(), _dynamic_requests.end());
return vector<Request*>();
return vector<Request*>(_dynamic_requests.begin(), _dynamic_requests.end());
}
void
@ -83,14 +80,13 @@ DynamicThread::remove_request(Request* request)
vector<DynamicRequest*>::iterator it;
// FIXME uncomment once requests are compelted
//it = std::find(_dynamic_requests.begin(), _dynamic_requests.end(), request);
it = std::find(_dynamic_requests.begin(), _dynamic_requests.end(), request);
//if(it != _dynamic_requests.end())
//{
// _dynamic_requests.erase(it);
// delete *it;
//}
if(it != _dynamic_requests.end())
{
_dynamic_requests.erase(it);
delete *it;
}
}

28
src/backend/request.cc Normal file
View File

@ -0,0 +1,28 @@
// src/backend/request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "request.hh"
using namespace sgpem;
Request::~Request()
{
}

54
src/backend/request.hh Normal file
View File

@ -0,0 +1,54 @@
// src/backend/request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef REQUEST_HH
#define REQUEST_HH 1
#include "config.h"
#include <vector>
namespace sgpem
{
class Request;
class SerializeVisitor;
class SubRequest;
class SG_DLLEXPORT Request
{
public:
enum state
{
state_ready,
state_allocated
};
virtual ~Request();
virtual std::vector<SubRequest*> get_subrequests() = 0;
virtual unsigned int get_instant() const = 0;
virtual state get_current_state() const = 0;
virtual void serialize(SerializeVisitor& translator) const = 0;
};
}
#endif

28
src/backend/resource.cc Normal file
View File

@ -0,0 +1,28 @@
// src/backend/resource.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "resource.hh"
using namespace sgpem;
Resource::~Resource()
{
}

46
src/backend/resource.hh Normal file
View File

@ -0,0 +1,46 @@
// src/backend/resource.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef RESOURCE_HH
#define RESOURCE_HH 1
#include "config.h"
#include "glibmm/ustring.h"
namespace sgpem
{
class Resource;
class SerializeVisitor;
class SG_DLLEXPORT Resource
{
public:
virtual ~Resource();
virtual Glib::ustring get_name() const = 0;
virtual unsigned int get_places() const = 0;
virtual void serialize(SerializeVisitor& translator) const = 0;
};
}
#endif

View File

@ -0,0 +1,44 @@
// src/backend/static_request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "static_request.hh"
#include <cassert>
using namespace sgpem;
StaticRequest::StaticRequest(StaticThread* thread,
unsigned int instant) :
_thread(thread), _instant(instant)
{
assert(thread != NULL);
}
unsigned int
StaticRequest::get_instant() const
{
return _instant;
}
StaticThread&
StaticRequest::get_thread()
{
return *_thread;
}

View File

@ -0,0 +1,51 @@
// src/backend/static_request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef STATIC_REQUEST_HH
#define STATIC_REQUEST_HH 1
#include "config.h"
#include "glibmm/ustring.h"
namespace sgpem
{
class StaticRequest;
class SerializeVisitor;
class StaticThread;
class StaticRequest
{
public:
StaticRequest(StaticThread* thread, unsigned int instant);
unsigned int get_instant() const;
StaticThread& get_thread();
private:
StaticRequest(const StaticRequest&);
StaticThread* _thread;
unsigned int _instant;
};
}
#endif

View File

@ -0,0 +1,42 @@
// src/backend/static_resource.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "static_resource.hh"
using namespace sgpem;
StaticResource::StaticResource(const Glib::ustring& name,
unsigned int places) :
_name(name), _places(places)
{
}
Glib::ustring
StaticResource::get_name() const
{
return _name;
}
unsigned int
StaticResource::get_places() const
{
return _places;
}

View File

@ -0,0 +1,50 @@
// src/backend/static_resource.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef STATIC_RESOURCE_HH
#define STATIC_RESOURCE_HH 1
#include "config.h"
#include "glibmm/ustring.h"
namespace sgpem
{
class StaticResource;
class SerializeVisitor;
class StaticResource
{
public:
StaticResource(const Glib::ustring& name, unsigned int places = 1);
Glib::ustring get_name() const;
unsigned int get_places() const;
private:
StaticResource(const StaticResource&);
Glib::ustring _name;
unsigned int _places;
};
}
#endif

View File

@ -0,0 +1,60 @@
// src/backend/static_sub_request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "static_sub_request.hh"
#include <cstddef>
#include <cassert>
using namespace sgpem;
StaticSubRequest::StaticSubRequest(StaticRequest* req,
StaticResource* resource,
unsigned int length,
unsigned int places) :
_static_request(req), _static_resource(resource),
_length(length), _places(places)
{
assert(req != NULL && resource != NULL);
}
StaticResource&
StaticSubRequest::get_static_resource()
{
return *_static_resource;
}
StaticRequest&
StaticSubRequest::get_static_request()
{
return *_static_request;
}
unsigned int
StaticSubRequest::get_places() const
{
return _places;
}
unsigned int
StaticSubRequest::get_length() const
{
return _length;
}

View File

@ -0,0 +1,60 @@
// src/backend/static_sub_request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef STATIC_SUB_REQUEST_HH
#define STATIC_SUB_REQUEST_HH 1
#include "config.h"
namespace sgpem
{
class StaticSubRequest;
class StaticRequest;
class StaticResource;
class StaticSubRequest
{
public:
StaticSubRequest(StaticRequest* req,
StaticResource* resource,
unsigned int length,
unsigned int places = 1);
StaticResource& get_static_resource();
StaticRequest& get_static_request();
unsigned int get_places() const;
unsigned int get_length() const;
private:
StaticSubRequest(const StaticSubRequest&);
StaticRequest* _static_request;
StaticResource* _static_resource;
unsigned int _length;
unsigned int _places;
};
}
#endif

View File

@ -19,6 +19,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "static_thread.hh"
#include "static_request.hh"
using namespace sgpem;
using std::vector;
@ -58,14 +59,13 @@ StaticThread::remove_request(StaticRequest* request)
vector<StaticRequest*>::iterator it;
// FIXME uncomment once requests are compelted
//it = std::find(_static_requests.begin(), _static_requests.end(), request);
it = std::find(_static_requests.begin(), _static_requests.end(), request);
//if(it != _static_requests.end())
//{
// _static_requests.erase(it);
// delete *it;
//}
if(it != _static_requests.end())
{
_static_requests.erase(it);
delete *it;
}
}
void

View File

@ -0,0 +1,28 @@
// src/backend/sub_request.cc - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "sub_request.hh"
using namespace sgpem;
SubRequest::~SubRequest()
{
}

View File

@ -0,0 +1,51 @@
// src/backend/sub_request.hh - Copyright 2005, 2006, University
// of Padova, dept. of Pure and Applied
// Mathematics
//
// This file is part of SGPEMv2.
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// SGPEMv2 is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with SGPEMv2; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef SUB_REQUEST_HH
#define SUB_REQUEST_HH 1
#include "config.h"
namespace sgpem
{
class SubRequest;
class SerializeVisitor;
class Resource;
class SG_DLLEXPORT SubRequest
{
public:
virtual ~SubRequest();
virtual Resource& get_resource() = 0;
virtual unsigned int get_places() const = 0;
virtual unsigned int get_length() const = 0;
virtual int get_queue_position() const = 0;
virtual void serialize(SerializeVisitor& translator) const = 0;
};
}
#endif

View File

@ -204,7 +204,7 @@ main(int argc, char** argv)
using Glib::Module;
//std::string command("ERERERT"); // the sequence of commands to test
std::string command("ERERERT"); // the sequence of commands to test
if(argc > 1)
command = argv[1];