thoughts on project 2


[ Follow Ups ] [ Post Followup ] [ CS328 Message Board ] [ FAQ ]

Posted by NR on July 12, 2001 at 22:59:45:

Hi people,

Thought I'd share some thoughts on project 2.

I think that all we need to turn in are the foohandler.h and foohandler.cpp files. Our foohandler class should inherit from abstract_foohandler, and override all of the virtual methods in the abstract class. In addition to doing that, it appears that we need to have another function somewhere in one of those two files that returns an instance of the foohandler that we have created. For example,

abstract_foohandler * create_handler()
{
// return a pointer to an instance of the foohandler
// class you have written
return new foohandler();
}


That way, in his test code, he can use the line

abstract_foohandler * test_handler_ptr = create_handler();

to start using our foohandler.

****
As for the foohandler methods....

I think I am going to have at least 2 data structures (maybe more) as private data members of the foohandler class. One of these data structures (I'm going to use a map), will hold the foos that you are caching.

So, if I have created 3 different types of foos (based on requests from various processes),

foo(1)
foo(17)
foo(18)

and I am storing them in memory for fast retrieval, the avltree under my map will look something like this

PAIR(17,foo(17))

PAIR(1,foo(1)) PAIR(18,foo(18))

Pair objects will be similar to the standard stl pair object, and have the <,>,= operators defined on the keys (in this example - 1,17,18). You need to store it something like this, because he said that the foos themselves may not have the comparison operators defined.

We also have to keep track of how many times each object is referencing various foos. So, if you receive the commands:

create_foo(A,1,x) x is returned as 1
create_foo(A,1,x) x is returned as 2
create_foo(A,17,y) y = 1
create_foo(A,17,y) y = 2
create_foo(A,17,y) y = 3
create_foo(B,1,z) z=1
create_foo(B,18,s) s = 1

You, will need to know that A has 2 references to the foo(1) object and 3 references to the foo(17) object. Also, B has one reference to the foo(1) object and one reference to the foo(18) object.

There are many different ways to keep track of the reference counts. I think I am going to try to keep them all in one map (as he mentioned in class) with a structure like the following

PAIR[SPECIAL_PAIR(A,17),2]

PAIR[SPECIAL_PAIR(A,1),2] PAIR[SPECIAL_PAIR(B,18),2]

The special pair will have the same structure as the generic pair object, but the comparators need to be a little different. They have to be based on the first and second element of the pair, instead of only the first element(the key).

You could also attempt to store each processes reference counts in a separate avl tree (you would have up to 255 of them - so you could keep them in an array or something). I'm not sure which would be better.

The hard part is keeping track of all of the reference counts.

And, the efficiency of the whole thing depends a lot on thinking about things like what Alan was talking about with his spam cake. I am going to try to make it work with these 2 data structures first, and then see if I can optimize it by keeping "success log" structures for the foos (ones that let you know you have had succes creating them in the past, so you can tell a process that you can have one ready without actually having to create it until they try to access it.

There also needs to be some additional bookkeeping to determine which foos to kick out when your cache gets too large. But, that is one of the things I will worry about a little later after I get something compiling.

Any thoughts?

Thanks,
Natalie


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS328 Message Board ] [ FAQ ]