Skip to content

Instantly share code, notes, and snippets.

View NightBrownie's full-sized avatar

Nikita Kliushnikov NightBrownie

View GitHub Profile
@sergiodxa
sergiodxa / async-thread.js
Last active June 27, 2023 05:38
Use WebWorkers and promises to run sync heavy functions in a worker (process) and get the result in a promise
function asyncThread(fn, ...args) {
if (!window.Worker) throw Promise.reject(
new ReferenceError(`WebWorkers aren't available.`)
);
const fnWorker = `
self.onmessage = function(message) {
(${fn.toString()})
.apply(null, message.data)
.then(result => self.postMessage(result));
@NightBrownie
NightBrownie / lab_4_1.cpp
Created April 27, 2011 17:13
Programming_lab_2_sem_4.1_var_9
// Lab_4_1_var-9.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <malloc.h>
#include <conio.h>
#define max_length 50
const char priority[4][2] = {{'+','1'},{'-','1'},{'*','2'},{'/','2'}}; //массив соответствия приоритета операциям