Skip to content
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

Commit 5687bcf

Browse files
authored
Document - Class DispatchQueue (#48)
* feat: document DQ.hpp * fix: typedef -> using = * fix: move include * fix: separate unused * fix: private -> protected * fix: construct * fix: remove unsed include
1 parent 119d255 commit 5687bcf

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

Backend/include/EasyContact/DispatchQueue.hpp

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,77 @@
1111
// C++ Standard Library
1212
#include <condition_variable>
1313
#include <functional>
14-
#include <iostream>
1514
#include <mutex>
16-
#include <string>
1715
#include <thread>
1816
// Standard Template Library
1917
#include <queue>
2018
#include <utility>
2119
#include <vector>
22-
// EasyContact Header Files
23-
#include <EasyContact/SingleUser.hpp>
2420
class DispatchQueue {
25-
typedef std::function<void(void)> Functor;
21+
using Functor = std::function<void(void)>;
2622

2723
private:
24+
bool inServices;
2825
size_t JobID;
2926
std::mutex Lock;
3027
std::vector<std::thread> Threads;
3128
std::queue<Functor> Queue;
3229
std::condition_variable CV;
33-
bool inServices = true;
30+
31+
protected:
3432
void Dispatch_Hander(void);
3533

3634
public:
35+
/**
36+
* Default Class Constructor
37+
* @param NumThreads : Number of Threads to Create
38+
*/
3739
explicit DispatchQueue(const size_t& NumThreads);
40+
/**
41+
* Default Class Destructor
42+
*/
3843
~DispatchQueue();
44+
/**
45+
* Add Task to Dispatch Queue
46+
* @param Operation : Task Expressed in Lambda Expression
47+
* @return std::pair<size_t, size_t> : Your Task ID, Number of Tasks Before
48+
* Your Task
49+
*/
3950
std::pair<size_t, size_t> Dispatch(const Functor& Operation);
51+
/**
52+
* Add Task to Dispatch Queue
53+
* @param Operation : Task Expressed in Lambda Expression
54+
* @return std::pair<size_t, size_t> : Your Task ID, Number of Tasks Before
55+
* Your Task
56+
*/
4057
std::pair<size_t, size_t> Dispatch(Functor&& Operation);
58+
59+
public:
60+
/**
61+
* This Funtion Call Is Not Allowed &
62+
* Will Delete Left Hand Side Instance
63+
* @param RHS : Another Instance of Current Class
64+
*/
4165
DispatchQueue(const DispatchQueue& RHS) = delete;
66+
/**
67+
* This Funtion Call Is Not Allowed &
68+
* Will Delete Left Hand Side Instance
69+
* @param RHS : Another Instance of Current Class
70+
* @return DispatchQueue : Reference to SELF
71+
*/
4272
DispatchQueue& operator=(const DispatchQueue& RHS) = delete;
73+
/**
74+
* This Funtion Call Is Not Allowed &
75+
* Will Delete Left Hand Side Instance
76+
* @param RHS : Another Instance of Current Class
77+
*/
4378
DispatchQueue(DispatchQueue&& RHS) = delete;
79+
/**
80+
* This Funtion Call Is Not Allowed &
81+
* Will Delete Left Hand Side Instance
82+
* @param RHS : Another Instance of Current Class
83+
* @return DispatchQueue : Reference to SELF
84+
*/
4485
DispatchQueue& operator=(DispatchQueue&& RHS) = delete;
4586
};
4687
#endif // BACKEND_INCLUDE_EASYCONTACT_DISPATCHQUEUE_HPP_

Backend/src/DispatchQueue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
*/
77
#ifndef BACKEND_SRC_DISPATCHQUEUE_CPP_
88
#define BACKEND_SRC_DISPATCHQUEUE_CPP_
9+
// EasyContact Header Files
910
#include <EasyContact/DispatchQueue.hpp>
11+
#include <EasyContact/SingleUser.hpp>
1012
DispatchQueue::DispatchQueue(const size_t& NumThreads)
11-
: JobID(0), Threads(NumThreads) {
13+
: inServices(true), JobID(0), Threads(NumThreads) {
1214
for (size_t i = 0; i < Threads.size(); ++i) {
1315
Threads[i] = std::thread(&DispatchQueue::Dispatch_Hander, this);
1416
}

0 commit comments

Comments
 (0)