mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-03 18:16:12 +01:00
Almost working
This commit is contained in:
parent
3bd401513d
commit
eaee625df4
@ -248,16 +248,20 @@ end
|
||||
(** GetTaskReply : Reply to the GetTask message *)
|
||||
module GetTaskReply_msg : sig
|
||||
type t
|
||||
val create : task_id:Id.Task.t -> task:string -> t
|
||||
val create : task_id:Id.Task.t option -> task:string option -> t
|
||||
val to_string : t -> string
|
||||
end = struct
|
||||
type t =
|
||||
{ task_id: Id.Task.t ;
|
||||
task : string ;
|
||||
{ task_id: Id.Task.t option ;
|
||||
task : string option ;
|
||||
}
|
||||
let create ~task_id ~task = { task_id ; task }
|
||||
let to_string x =
|
||||
Printf.sprintf "get_task_reply %d %s" (Id.Task.to_int x.task_id) x.task
|
||||
match x.task_id, x.task with
|
||||
| Some task_id, Some task ->
|
||||
Printf.sprintf "get_task_reply %d %s" (Id.Task.to_int task_id) task
|
||||
| _ ->
|
||||
Printf.sprintf "get_task_reply 0"
|
||||
end
|
||||
|
||||
(** GetPsi : get the current variational wave function *)
|
||||
|
@ -99,9 +99,12 @@ let del_task ~task_id q =
|
||||
|
||||
|
||||
|
||||
let number_of_queued q =
|
||||
let number q =
|
||||
Map.length q.tasks
|
||||
|
||||
let number_of_queued q =
|
||||
List.length q.queued
|
||||
|
||||
let number_of_running q =
|
||||
Map.length q.running
|
||||
|
||||
|
@ -305,8 +305,7 @@ let del_task msg program_state rep_socket =
|
||||
}
|
||||
in
|
||||
let more =
|
||||
(Queuing_system.number_of_queued new_program_state.queue +
|
||||
Queuing_system.number_of_running new_program_state.queue) > 0
|
||||
(Queuing_system.number new_program_state.queue > 0)
|
||||
in
|
||||
Message.DelTaskReply (Message.DelTaskReply_msg.create ~task_id ~more)
|
||||
|> Message.to_string
|
||||
@ -427,21 +426,10 @@ let get_task msg program_state rep_socket pair_socket =
|
||||
}
|
||||
in
|
||||
|
||||
match (task, task_id) with
|
||||
| Some task, Some task_id ->
|
||||
begin
|
||||
Message.GetTaskReply (Message.GetTaskReply_msg.create ~task ~task_id)
|
||||
|> Message.to_string
|
||||
|> ZMQ.Socket.send rep_socket ;
|
||||
new_program_state
|
||||
end
|
||||
| _ ->
|
||||
begin
|
||||
Message.Terminate (Message.Terminate_msg.create ())
|
||||
|> Message.to_string
|
||||
|> ZMQ.Socket.send rep_socket ;
|
||||
program_state
|
||||
end
|
||||
|
||||
in
|
||||
|
||||
@ -601,6 +589,7 @@ let start_pub_thread ~port =
|
||||
else
|
||||
state
|
||||
in
|
||||
print_endline (string_of_pub_state new_state);
|
||||
ZMQ.Socket.send pub_socket @@ string_of_pub_state new_state;
|
||||
match state with
|
||||
| Stopped -> ()
|
||||
|
Loading…
Reference in New Issue
Block a user