mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 14:58:18 +00:00
job: Add a maxmem
parameter to job_start
The value is forwarded to it's own WStream instance
This commit is contained in:
@@ -10474,6 +10474,7 @@ static void f_job_start(typval_T *argvars, typval_T *rettv)
|
|||||||
on_job_stderr,
|
on_job_stderr,
|
||||||
on_job_exit,
|
on_job_exit,
|
||||||
true,
|
true,
|
||||||
|
0,
|
||||||
&rettv->vval.v_number);
|
&rettv->vval.v_number);
|
||||||
|
|
||||||
if (rettv->vval.v_number <= 0) {
|
if (rettv->vval.v_number <= 0) {
|
||||||
|
@@ -80,6 +80,7 @@ bool channel_from_job(char **argv)
|
|||||||
job_err,
|
job_err,
|
||||||
job_exit,
|
job_exit,
|
||||||
true,
|
true,
|
||||||
|
0,
|
||||||
&status);
|
&status);
|
||||||
|
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
@@ -104,7 +105,7 @@ void channel_from_stream(uv_stream_t *stream)
|
|||||||
rstream_set_stream(channel->data.streams.read, stream);
|
rstream_set_stream(channel->data.streams.read, stream);
|
||||||
rstream_start(channel->data.streams.read);
|
rstream_start(channel->data.streams.read);
|
||||||
// write stream
|
// write stream
|
||||||
channel->data.streams.write = wstream_new(1024 * 1024);
|
channel->data.streams.write = wstream_new(0);
|
||||||
wstream_set_stream(channel->data.streams.write, stream);
|
wstream_set_stream(channel->data.streams.write, stream);
|
||||||
channel->data.streams.uv = stream;
|
channel->data.streams.uv = stream;
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
#define EXIT_TIMEOUT 25
|
#define EXIT_TIMEOUT 25
|
||||||
#define MAX_RUNNING_JOBS 100
|
#define MAX_RUNNING_JOBS 100
|
||||||
#define JOB_BUFFER_SIZE 1024
|
#define JOB_BUFFER_SIZE 1024
|
||||||
#define JOB_WRITE_MAXMEM 1024 * 1024
|
|
||||||
|
|
||||||
struct job {
|
struct job {
|
||||||
// Job id the index in the job table plus one.
|
// Job id the index in the job table plus one.
|
||||||
@@ -131,6 +130,7 @@ void job_teardown()
|
|||||||
/// @param exit_cb Callback that will be invoked when the job exits
|
/// @param exit_cb Callback that will be invoked when the job exits
|
||||||
/// @param defer If the job callbacks invocation should be deferred to vim
|
/// @param defer If the job callbacks invocation should be deferred to vim
|
||||||
/// main loop
|
/// main loop
|
||||||
|
/// @param maxmem Maximum amount of memory used by the job WStream
|
||||||
/// @param[out] The job id if the job started successfully, 0 if the job table
|
/// @param[out] The job id if the job started successfully, 0 if the job table
|
||||||
/// is full, -1 if the program could not be executed.
|
/// is full, -1 if the program could not be executed.
|
||||||
/// @return The job pointer if the job started successfully, NULL otherwise
|
/// @return The job pointer if the job started successfully, NULL otherwise
|
||||||
@@ -140,6 +140,7 @@ Job *job_start(char **argv,
|
|||||||
rstream_cb stderr_cb,
|
rstream_cb stderr_cb,
|
||||||
job_exit_cb job_exit_cb,
|
job_exit_cb job_exit_cb,
|
||||||
bool defer,
|
bool defer,
|
||||||
|
size_t maxmem,
|
||||||
int *status)
|
int *status)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -210,7 +211,7 @@ Job *job_start(char **argv,
|
|||||||
handle_set_job((uv_handle_t *)&job->proc_stdout, job);
|
handle_set_job((uv_handle_t *)&job->proc_stdout, job);
|
||||||
handle_set_job((uv_handle_t *)&job->proc_stderr, job);
|
handle_set_job((uv_handle_t *)&job->proc_stderr, job);
|
||||||
|
|
||||||
job->in = wstream_new(JOB_WRITE_MAXMEM);
|
job->in = wstream_new(maxmem);
|
||||||
wstream_set_stream(job->in, (uv_stream_t *)&job->proc_stdin);
|
wstream_set_stream(job->in, (uv_stream_t *)&job->proc_stdin);
|
||||||
// Start the readable streams
|
// Start the readable streams
|
||||||
job->out = rstream_new(read_cb, JOB_BUFFER_SIZE, job, defer);
|
job->out = rstream_new(read_cb, JOB_BUFFER_SIZE, job, defer);
|
||||||
|
Reference in New Issue
Block a user