allow a request to be processed in a job
Now we allow a request to be passed into a job queue, and after the job finishes the request is passed into a controller again. In order to achieve this we have a requests queue in System, when we put a request to the job this Request structure is preserved in the queue and for a new request a new Request is added to the queue. while here: - remove App::Lock()/Unlock(), use scoped locking - fix: Plugin now has a Call method which takes ModelConnector and a logger (used in multithreaded environment) - BaseThread has a main_model_connector pointer to the main (from the main thread) model connector - the FastCGI structure fcgi_request moved from App to Request - some methods for handling requests moved from App to Request - small refactoring in main.cpp - add Http class (a http client)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012-2014, Tomasz Sowa
|
||||
* Copyright (c) 2012-2022, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -32,22 +32,26 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef headerfile_winix_core_jobs
|
||||
#define headerfile_winix_core_jobs
|
||||
#ifndef headerfile_winix_core_job
|
||||
#define headerfile_winix_core_job
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include "basethread.h"
|
||||
#include "space/space.h"
|
||||
#include "jobtask.h"
|
||||
#include "cur.h"
|
||||
#include "loadavg.h"
|
||||
#include "mounts.h"
|
||||
|
||||
|
||||
|
||||
namespace Winix
|
||||
{
|
||||
class Functions;
|
||||
|
||||
|
||||
|
||||
#define WINIX_JOBS_HOW_MANY_PRIORITIES 32
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -55,19 +59,35 @@ class Job : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
static const size_t PRIORITY_LOWEST = 0;
|
||||
static const size_t PRIORITY_HIGHEST = 31;
|
||||
|
||||
static const size_t PRIORITY_DEFAULT = 16;
|
||||
static const size_t PRIORITY_REQUEST_CONTINUATION = 17;
|
||||
|
||||
|
||||
Job();
|
||||
|
||||
void SetCur(Cur * cur);
|
||||
void SetFunctions(Functions * functions);
|
||||
void SetLoadAvg(LoadAvg * load_avg);
|
||||
void SetMounts(Mounts * mounts);
|
||||
void SetReqTab(std::list<Request> * req_tab);
|
||||
|
||||
/*
|
||||
add a new job to the queue
|
||||
priority: 0-31 (0 - the lowest priority, 31 - the highest priority)
|
||||
*/
|
||||
void Add(pt::Space & job, int priority = 0);
|
||||
void Add(pt::Space & job, size_t priority = PRIORITY_DEFAULT);
|
||||
void Add(Request * request, pt::Space & job, size_t priority = PRIORITY_DEFAULT);
|
||||
|
||||
void Add(long job_id, pt::Space & job, size_t priority = PRIORITY_DEFAULT);
|
||||
void Add(long job_id, Request * request, pt::Space & job, size_t priority = PRIORITY_DEFAULT);
|
||||
|
||||
/*
|
||||
queue size, and size of all jobs in any priority
|
||||
*/
|
||||
size_t Size(int priority) const;
|
||||
size_t Size(size_t priority) const;
|
||||
size_t Size() const;
|
||||
|
||||
|
||||
@@ -75,17 +95,23 @@ public:
|
||||
true if specified queue is empty
|
||||
or if all queues are empty
|
||||
*/
|
||||
bool Empty(int priority) const;
|
||||
bool Empty(size_t priority) const;
|
||||
bool Empty() const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
typedef std::queue<pt::Space> JobsQueue;
|
||||
Cur * cur;
|
||||
Functions * functions;
|
||||
LoadAvg * load_avg;
|
||||
Mounts * mounts;
|
||||
std::list<Request> * req_tab;
|
||||
|
||||
typedef std::queue<JobTask> JobsQueue;
|
||||
typedef std::vector<JobsQueue> JobsQueueTab;
|
||||
JobsQueueTab jobs_queue_tab;
|
||||
|
||||
void CheckPriority(int & priority) const;
|
||||
void CheckPriority(size_t & priority) const;
|
||||
void SaveToFile();
|
||||
void ReadFromFile();
|
||||
|
||||
@@ -101,9 +127,11 @@ private:
|
||||
|
||||
bool SignalReceived();
|
||||
void Do();
|
||||
void DoQueue(JobsQueue & jobs_queue);
|
||||
void DoJob(pt::Space & job);
|
||||
void DoQueue(JobsQueue & jobs_queue, size_t priority);
|
||||
void DoJob(JobTask & task, size_t priority);
|
||||
void DoRequestContinuationJob(JobTask & job_task, size_t priority);
|
||||
void DoWinixJob(pt::Space & job);
|
||||
void RemoveOldRequest(Request * request);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user