56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
# You are free to use and/or change this code for
|
|
# your own needs.
|
|
|
|
# Original code (c)2018 Jan Lerking
|
|
# Program to convert C-header (*.h) files to nasm include files (*.inc),
|
|
# for direct usage in assembly programming using nasm/yasm.
|
|
|
|
import multiprocessing
|
|
from queue import Queue
|
|
from threading import Thread
|
|
import threading
|
|
import globvar
|
|
import h2inc_fp
|
|
import time
|
|
|
|
lock = threading.Lock()
|
|
|
|
def process_queue():
|
|
print("Worker {} working...".format(threading.current_thread().name))
|
|
#for i in range(self.filecnt):
|
|
#proportion = (float(i+1))/self.filecnt
|
|
#self.queue.put((proportion, "working...", i))
|
|
#time.sleep(0.01)
|
|
#process_file(filelist[i])
|
|
#self.queue.put((1.0, "finished"))
|
|
#print("The worker has finished.")
|
|
while True:
|
|
cfile = globvar.queue.get()
|
|
print(cfile)
|
|
h2inc_fp.process_file(cfile)
|
|
globvar.queue.task_done()
|
|
|
|
def start_workers():
|
|
print("Creating shared Queue")
|
|
ts = time.time()
|
|
globvar.queue = Queue()
|
|
|
|
print("Number of cores:", globvar.num_cores)
|
|
|
|
for n in range(globvar.num_cores):
|
|
print("Creating Worker", n)
|
|
|
|
worker = threading.Thread(target=process_queue)
|
|
worker.deamon = True
|
|
worker.start()
|
|
|
|
for cfile in globvar.filelist:
|
|
print("Queueing {}".format(cfile))
|
|
globvar.queue.put(cfile)
|
|
|
|
globvar.queue.join()
|
|
te = time.time()-ts
|
|
print("Processing time: ", te)
|
|
return
|
|
|