Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Inf3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcel Kehrberg
Inf3
Commits
3cce90e9
Commit
3cce90e9
authored
2 years ago
by
Michael Ghebremussie
Browse files
Options
Downloads
Patches
Plain Diff
Added Comments to the Buffer and removes white Spaces
parent
0113a6f8
No related branches found
No related tags found
2 merge requests
!3
Added Comments to the Buffer and removes white Spaces
,
!1
Added Comments to the Buffer and removes white Spaces
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Aufgabe3/ConsoleApplication1/Buffer.cs
+14
-3
14 additions, 3 deletions
Aufgabe3/ConsoleApplication1/Buffer.cs
Aufgabe3/ConsoleApplication1/Producer.cs
+0
-1
0 additions, 1 deletion
Aufgabe3/ConsoleApplication1/Producer.cs
with
14 additions
and
4 deletions
Aufgabe3/ConsoleApplication1/Buffer.cs
+
14
−
3
View file @
3cce90e9
...
...
@@ -4,31 +4,40 @@ using System.Threading;
namespace
ConsoleApplication1
{
/// <summary>
/// Created a Class Buffer that contains a Queue which represents the "Garage".
/// The Queue is limited by the size
/// </summary>
public
class
Buffer
{
private
Queue
<
Car
>
carQueue
;
private
int
size
=
10
;
private
Mutex
mutex
;
// The Buffer has a Mutex and a Queue
public
Buffer
()
{
mutex
=
new
Mutex
();
carQueue
=
new
Queue
<
Car
>();
}
// This functions adds a Car object into the Queue
public
void
push
(
Car
c
)
{
// Throws an Exception if the Buffer size equals size
if
(
carQueue
.
Count
==
size
)
{
throw
new
Exception
(
"Buffer full"
);
}
// Adds the passed Car object with the default Enqueue method
carQueue
.
Enqueue
(
c
);
}
// removes a Car from the Queue and returns the Queue
public
Car
pop
()
{
// Throws an Exception if the Buffer size equals 0
if
(
carQueue
.
Count
==
0
)
{
throw
new
Exception
(
"Buffer empty"
);
...
...
@@ -37,6 +46,7 @@ namespace ConsoleApplication1
return
carQueue
.
Dequeue
();
}
// returns a wheather the Queue is full or not
public
bool
full
()
{
bool
isFull
=
false
;
...
...
@@ -48,6 +58,7 @@ namespace ConsoleApplication1
return
isFull
;
}
// returns a wheather the Queue is empty or not
public
bool
empty
()
{
if
(
carQueue
.
Count
==
0
)
...
...
@@ -58,11 +69,11 @@ namespace ConsoleApplication1
return
false
;
}
// returns the mutex
public
Mutex
getMutex
()
{
return
this
.
mutex
;
}
}
}
This diff is collapsed.
Click to expand it.
Aufgabe3/ConsoleApplication1/Producer.cs
+
0
−
1
View file @
3cce90e9
...
...
@@ -3,7 +3,6 @@ using System.Threading;
namespace
ConsoleApplication1
{
public
class
Producer
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment