Yurttas/PL/OOL/Cplusplus/F/02/08/01/00/cubby hole.cpp

Revision as of 21:50, 6 November 2013 by MassBot1 (talk | contribs) (Created page with "<syntaxhighlight lang="cpp" line start="1" enclose="div">/* Copyright(C) 2005 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc.. Perm...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 1/*
 2   Copyright(C) 2005
 3   All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4
 5   Permission to use, copy, modify, and distribute this
 6   software and its documentation for EDUCATIONAL purposes
 7   and without fee is hereby granted provided that this
 8   copyright notice appears in all copies.
 9 
10   date   : September 1, 2005.
11   author : Austin W. Westfall, Salih Yurttas.
12
13   cubby_hole.cpp
14*/
15
16
17#ifndef CUBBY_HOLE_CPP
18#define CUBBY_HOLE_CPP
19
20#include "cubby_hole.h"
21
22template<class T>
23cubby_hole<T>::
24cubby_hole(const int max_size) : max_size(max_size) {
25}
26
27template<class T>
28cubby_hole<T>::
29~cubby_hole() {
30  mut.lock();
31  while(data.size()>0)
32    data.pop();
33  mut.unlock();
34}
35
36template<class T>
37int
38cubby_hole<T>::
39size() const {
40  mut.lock();
41  int result = data.size();
42  mut.unlock();
43  return result;
44}
45
46template<class T>
47void
48cubby_hole<T>::
49put(T item) {
50  mut.lock();
51  data.push(item);
52  mut.unlock();
53}
54
55template<class T>
56T
57cubby_hole<T>::
58get() {
59  mut.lock();
60  T item = data.front();
61  data.pop();
62  mut.unlock();
63  return item;
64}
65#endif