task

Exact algorithm for task scheduling on N identical processors?

南楼画角 提交于 2019-12-06 09:23:39
问题 I'm looking for exact algorithm which find the best solution on task schedule in N identical processors. The time of this algorithm is not important, the most important is one best solution (miminum time of all processors when the last task will be finished). In theory equation describing this algorithm is as follows: P||Cmax If anyone has an algorithm (especially in Java) or pseudocode I will be grathefull for help. I tried write my own exact algoritm but id doesn't work :(. In the code

Android - Background activity bring itself to foreground

狂风中的少年 提交于 2019-12-06 08:22:38
I have the following situation: Activity A starts activity B User presses Home button & starts another app After a while, I want activity B to bring itself (not create new instance) to foreground How can I do this? I tried using intents with FLAG_ACTIVITY_REORDER_TO_FRONT, FLAG_FROM_BACKGROUND and set B's launch mode as singleTask, singleInstance but none of them work. Just use this method in your activity as per your situation. it will work. protected void moveToFront() { if (Build.VERSION.SDK_INT >= 11) { // honeycomb final ActivityManager activityManager = (ActivityManager) getSystemService

Do I need to worry about blocking tasks?

社会主义新天地 提交于 2019-12-06 08:17:20
问题 How much do I need to worry about blocking tasks in .NET? i.e. how does the .NET task scheduler handle blocking of threads in the thread pool and oversubscription? E.g. if I have some IO in a task, should I always create it with the LongRunning hint? Or does the task scheduler heuristics handle it better? In C++ there is an Oversubscribe hint which works perfectly but I have not found any equivalent in .NET. 回答1: The ThreadPool does detect when one of its threads blocks and it is a hint for

How can to run task in 5 minutes after finish previous task using celery-beat?

烈酒焚心 提交于 2019-12-06 08:09:35
问题 I have a two tasks - a and b . Task a running in 5 minutes after finish previous task a . Task b running in 3 minutes after finish previous task b . How can I implement it? I'm use python 3.6.8 , Django 2.2.6 and celery 4.3.0 ? 回答1: The short answer is that you can't do this with celery beat because celery beat will trigger off of task start and not at task end. If you absolutely need to do it three minutes after the previous task ends, you'd be advised to just adding a call to .apply_async

concat result of three tasks in an async method in a proper way

孤街醉人 提交于 2019-12-06 07:36:33
I am very new in async programming. I was wonder if there is any way for these tasks to run simultaneously. Consider I have this code: public async Task<IList<WebData>> GetAllAsync() { var twitterData = await ProvidetwitterDataAsync(); var facebookData = await ProvidefacebookDataAsync(); var linkedinData = await ProvidelinkedinDataAsync(); return twitterData .Concat(facebookData ).Concat(linkedinData ).ToList(); } I think because I used await twitterData that Task should be done and after that next Task will be started, because I wanted to concat results of these three lists I wrote it in this

Accessing grails application config from a quartz job

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 07:16:56
Using grails 2.4.2, quartz:1.0.2, I'm trying to gain access to configuration properties class MyJob { def grailsApplication int propA def MyJob() { propA = grailsApplication.config.foo.bar.propAVal } ... } grailsApplication, however, doesn't get injected, and is null. Can't access any bean from Quartz Job in Grails supposedly relates to this, but I don't really see how the marked answer resolves the OP's question :-/ help? 10x The problem is probably that you are accessing grailsApplication in constructor, where it's not injected yet. I recommend to dump useless class property int propA and do

Automatic task execution on google app engine development server (python)

霸气de小男生 提交于 2019-12-06 06:45:30
问题 The docs for the python dev server say this about running tasks: When your app is running in the development server, task queues are not processed automatically. Instead, task queues accrue tasks which you can examine and execute from the developer console... But the release notes for version 1.3.4 of the python sdk (which I am using) say: Auto task execution is now enabled in the dev_appserver. To turn this off use the flag --disable_task_running. So maybe the docs are a little behind, right

C# async within an action

谁都会走 提交于 2019-12-06 05:35:15
问题 I would like to write a method which accept several parameters, including an action and a retry amount and invoke it. So I have this code: public static IEnumerable<Task> RunWithRetries<T>(List<T> source, int threads, Func<T, Task<bool>> action, int retries, string method) { object lockObj = new object(); int index = 0; return new Action(async () => { while (true) { T item; lock (lockObj) { if (index < source.Count) { item = source[index]; index++; } else break; } int retry = retries; while

How to check possibility of deadlock in c# code

人盡茶涼 提交于 2019-12-06 05:33:02
问题 My application sometimes stop in the below code, not always but sometimes. All the 3 methods CalcQuarterlyFigures , CalcWeeklyFigures & CalcMonthlyFigures return Task<List<MyClass>> . Note, this runs inside a foreach loop. List<Task> TaskList = new List<Task>(); if(i.DoCalculateAllHistory) { var quarterly = CalcQuarterlyFigures(QuarterlyPrices, i.SeriesID); TaskList.Add(quarterly); var weekly = CalcWeeklyFigures(WeeklyPrices, i.SeriesID); TaskList.Add(weekly); var monthly = CalcMonthlyFigures

awaiting task with timeout

╄→尐↘猪︶ㄣ 提交于 2019-12-06 03:45:59
问题 I'm trying to write a helper method which allows me to pass in an arbitrary task and a timeout. If the task completes before the timeout, a success delegate is called, otherwise an error delegate is called. The method looks like this: public static async Task AwaitWithTimeout(Task task, int timeout, Action success, Action error) { if (await Task.WhenAny(task, Task.Delay(timeout)) == task) { if (success != null) { success(); } } else { if (error != null) { error(); } } } Now this seems to work