s********e 发帖数: 243 | 1 Write an object(class), called StockCache, that caches a single stock every
couple of minutes. What are the function prototypes? Where would you need to
put in thread protection? How would you organize the set of StockCache
objects?
我没啥思路,牛人们给指点一下。大概需要哪些member variables/functions. 关于
thread protection的问题怎么考虑?多谢了!! |
s********e 发帖数: 243 | |
d**e 发帖数: 6098 | 3 我猜的
int cache_size ?
float[] cache ?
void updateCache(float value) ?
float getValueAt(int time) ?
updateCache需要上锁,防止多个线程同时更新。
every
to
【在 s********e 的大作中提到】 : Write an object(class), called StockCache, that caches a single stock every : couple of minutes. What are the function prototypes? Where would you need to : put in thread protection? How would you organize the set of StockCache : objects? : 我没啥思路,牛人们给指点一下。大概需要哪些member variables/functions. 关于 : thread protection的问题怎么考虑?多谢了!!
|
e****e 发帖数: 418 | 4 When we have a set of StockCache objects and a stock A to be cached, how do
we know if there is a StockCache object already holds a stock A of the last-
time version.
If true, the current version of stock A should replace the old one in the
StockCache object.
If not true, a new StockCache is created to hold the current version of
stock A object.
So we should have a StockCacheManager to do such check. We can replace a
existing stock cache or add a new stock cache through StockCacheManager. And
it |
s********e 发帖数: 243 | 5 思路太清楚了啊!
热切期待您的TBC。。。
do
last-
And
【在 e****e 的大作中提到】 : When we have a set of StockCache objects and a stock A to be cached, how do : we know if there is a StockCache object already holds a stock A of the last- : time version. : If true, the current version of stock A should replace the old one in the : StockCache object. : If not true, a new StockCache is created to hold the current version of : stock A object. : So we should have a StockCacheManager to do such check. We can replace a : existing stock cache or add a new stock cache through StockCacheManager. And : it
|
s*****n 发帖数: 5488 | 6 public class stock
{
private string StockId;
private Quote bars[];
}
public class quote{
//define TOCHLV here
}
public class StockCache
{
Stock stock;
Quote[] bars = new Quotes[const int length];
// access method
public void AssignStock(Stock s ){this.stock = s};
public void ReplaceBar(Quote bar);
public void RemoveBar(DateTIme minute);
public bar GetBar(Datetime minute);
public void clear();
public void
//properties
public int BarCount
}
put monitor on stock obj, Quote class, and you should
【在 s********e 的大作中提到】 : Write an object(class), called StockCache, that caches a single stock every : couple of minutes. What are the function prototypes? Where would you need to : put in thread protection? How would you organize the set of StockCache : objects? : 我没啥思路,牛人们给指点一下。大概需要哪些member variables/functions. 关于 : thread protection的问题怎么考虑?多谢了!!
|
c****o 发帖数: 41 | 7 也许应该用到写优先的readerwriterlock,这样可以允许多个线程读cache |